| Author |
which one is recommended ?
|
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
which one is good practice & recommended for projects : Thanks .
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
This has got nothing to do with the performance. I would prefer the 2nd option to avoid simple mistakes. Both are okay to use.  [ April 08, 2005: Message edited by: Pradeep Bhat ]
|
Groovy
|
 |
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
|
|
This is more a matter of style, and errors usually occur when mixing styles. Therefore, no matter what you choose, whetherA(int a) { this.a = a; }A(int arg) { this.a = arg; }A(int arg) { a = arg; }A(int _a) { this.a = _a; }A(int _a) { a = _a; } or something else, be consistent, and if you're editing someone else's code, follow their style or change all constructors to match the project's style if that's appropriate.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
Moving to Java in General (beginners)...
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Pradeep Bhat: I would prefer the 2nd option to avoid simple mistakes.[/QB]
I prefer the 1st, partly because I use an IDE with color highlights fields differently from local variables and warns me about the most common mistake (assigning the field to itself). I agree with David, though: Most important is that you do it consistently (throughout the whole team, if you are not working alone).
|
 |
Richard Munde
Greenhorn
Joined: Feb 18, 2005
Posts: 6
|
|
|
Which IDE do you use?
|
 |
magic zha
Greenhorn
Joined: Mar 25, 2005
Posts: 24
|
|
I preffer the first one ,because I don't need to think the new parameter's name!
|
 |
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Thanks for inputs , Can any body tell me , which is the forum , where I can post best practice ( what is recommended & what is not ) type of questions ... Thanks .
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by magic zha: I preffer the first one ,because I don't need to think the new parameter's name!
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Originally posted by Ilja Preuss: I prefer the 1st, partly because I use an IDE with color highlights fields differently from local variables and warns me about the most common mistake (assigning the field to itself). I agree with David, though: Most important is that you do it consistently (throughout the whole team, if you are not working alone).
I agree but I rarely use an IDE I prefer Textpad.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Richard Munde: Which IDE do you use?
Eclipse.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Pradeep Bhat: I agree but I rarely use an IDE I prefer Textpad.
When I started, I used Textpad, too. But once I got the hang of how the basics work, switching to an IDE made me way more productive.
|
 |
 |
|
|
subject: which one is recommended ?
|
|
|