File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is better?

 
Amy Phillips
Ranch Hand
Posts: 280
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 867
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
adi peretz
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic