| Author |
Which is better?
|
Amy Phillips
Ranch Hand
Joined: Apr 02, 2003
Posts: 280
|
|
Should I pass two numbers into a method or just pass one number and use it to calculate the second? I know I can do it both ways so which should I choose?
|
 |
Elouise Kivineva
Ranch Hand
Joined: Feb 07, 2002
Posts: 154
|
|
If you can do something just once, why do it twice? Use "number A" to calulate "number B" and then decide where the code that does this calculation should go. If the calcualtion is simple, you could just forget even having a second variable. If for example B = (4 * A), you could just have A and (4*A).
|
 |
Francis Siu
Ranch Hand
Joined: Jan 04, 2003
Posts: 867
|
|
hi Amy I think that the coding should be keep clear and sample, the method is used to hiding the coding,procedure calculation. So, I perfer to use method to do something,it is also the concept of the encapsulation. (Hope that I without explain wrong of the encapsulation ) HTH
|
Francis Siu
SCJP, MCDBA
|
 |
adi peretz
Greenhorn
Joined: Jun 14, 2003
Posts: 5
|
|
hi, if you can do what you want with sending one number then use only one number the variables and arguments you use the better
|
 |
 |
|
|
subject: Which is better?
|
|
|