wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Which is better?" Watch "Which is better?" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which is better?
 
Similar Threads
Passing my object to one to other activity
how to make an object synchronized
Single rmi invocation for String[] or multiple invocations for each String.
Help me
on lost focus of textbox. + JSP + Server side Validation.