Should I add parameters to instance methods that use those instance fields as parameters?
Posted
by
john smith optional
on Programmers
See other posts from Programmers
or by john smith optional
Published on 2012-10-01T09:27:26Z
Indexed on
2012/10/01
15:52 UTC
Read the original article
Hit count: 380
java
|design-patterns
I have an instance method that uses instance fields in its work. I can leave the method without that parameters as they're available to me, or I can add them to the parameter list, thus making my method more "generic" and not reliable on the class. On the other hand, additional parameters will be in parameters list. Which approach is preferable and why?
Edit: at the moment I don't know if my method will be public or private.
Edit2: clarification: both method and fields are instance level.
© Programmers or respective owner