This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Which is better? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Which is better?" Watch "Which is better?" New topic

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 )

Francis Siu
adi peretz

Joined: Jun 14, 2003
Posts: 5
if you can do what you want with sending one
number then use only one number the variables
and arguments you use the better
I agree. Here's the link:
subject: Which is better?
jQuery in Action, 3rd edition