File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Best approach to write helper private methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Best approach to write helper private methods" Watch "Best approach to write helper private methods" New topic
Author

Best approach to write helper private methods

Zbyszko Palka
Greenhorn

Joined: Nov 10, 2006
Posts: 13
Hello,
What is the best way (practice) to write helper private method:

a) Method operate on instance variable 'someData'



b) ... or method operate on variable passed to it, and return result



BR
Zbyszko
[ August 12, 2007: Message edited by: Zbyszko Palka ]
Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 136
    
    1
I would vote for the first method. I think it is better that passing member data be left out. In the future, if the member data format is changed, the second format must always be changed, whereas the first format may not have to be.

The first format is also easily changed to a public method in the future should it turn out that has some usefulness.

I think the second technique (data in, data out, with no member data modified) would be best when declared public static, in cases where external methods would also have some use for it in a general purpose way.
[ August 12, 2007: Message edited by: Red Smith ]
Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 136
    
    1
duplicate
[ August 12, 2007: Message edited by: Red Smith ]
Zbyszko Palka
Greenhorn

Joined: Nov 10, 2006
Posts: 13
Thanks for your reply.

For me the first approach is more OO. It operate on objects variable. But from the other hand when I'am reading such code:



I can't find that doA and doB perform operations on someData. It is not clear ...

Hmmm, looks like there is no 'best approach', all depends on situation

Thanks!
Zbyszko
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best approach to write helper private methods
 
Similar Threads
Please explain the concept of private constructor
I can access private variable?? pl give me reason..
Method-Inner class
List's contains(Object o) method doesn't work for object version.
I can access private variable??