Results 1 to 11 of 11
  1. #1
    shruti7 is offline Member
    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Default good programming practise

    is allowing funtions to change parameters a good programming practise

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: good programming practise

    Can you give a concrete example about function to change parameters?

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: good programming practise

    Quote Originally Posted by shruti7 View Post
    is allowing funtions to change parameters a good programming practise
    If the designers of the Java language had thought it to be a bad idea they would've made parameters 'final' by default. Change them if you need to; if you're trying to circumvent it at all cost, you'll end up with silly little artifacts in your code.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: good programming practise

    ... and Java has methods. Not functions.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: good programming practise

    An ArrayList would be significantly less useful if there were no methods to add or remove elements from its underlying array.

    ETA: Ignore the above, it's nonsense based on thinking we were talking about attributes, not parameters.
    Changing parameters is generally considered bad practice.
    Last edited by Tolls; 01-23-2013 at 11:41 AM.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: good programming practise

    Quote Originally Posted by Tolls View Post
    An ArrayList would be significantly less useful if there were no methods to add or remove elements from its underlying array.
    Strictly speaking, if that ArrayList were a parameter, you're not changing the parameter value if you add or remove an element to/from that ArrayList.
    </pedantic>

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: good programming practise

    Oh bugger.
    I read "parameter" as "attribute".
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: good programming practise

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: good programming practise

    Quote Originally Posted by Tolls View Post
    Oh bugger.
    I read "parameter" as "attribute".
    Hrmph, I first read it as 'halibut' and then the question didn't make any sense because halibuts do want to be changed; into a penguin or an aardvark or a prime minister, or ... or ...

    kind regards,

    Jos (sorry, it won't happen again)
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: good programming practise

    I sometimes wonder if our PM was a halibut...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: good programming practise

    Quote Originally Posted by Tolls View Post
    I sometimes wonder if our PM was a halibut...
    PM? I didn't get no PM from you; f.y.i I didn't get PMs from a herring either ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Good Practice Programming Websites?
    By littlebirdpoo in forum New To Java
    Replies: 1
    Last Post: 02-18-2012, 03:58 PM
  2. Replies: 2
    Last Post: 01-17-2012, 06:04 PM
  3. Hello Good Morning, Good afternoon, and Good Evening
    By MrFreeweed in forum Introductions
    Replies: 3
    Last Post: 12-11-2009, 04:32 PM
  4. [SOLVED] Is this good programming practice?
    By porchrat in forum New To Java
    Replies: 9
    Last Post: 04-08-2009, 01:54 PM
  5. Replies: 1
    Last Post: 08-07-2007, 06:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •