On one end of the spectrum, all inputs and potentially even all outputs of a method could be passed in as arguments.
On the other end of the spectrum, a method might require no arguments at all, somehow fetching all it needs through registers, member variables and calling methods of other objects.
In reality, long lists of parameters and the use of output parameters tend to be rare, so that the more commonly used spectrum is somewhere between methods with a few input parameters and methods requiring no parameters.
The question is then: having the choice, why should one lean more toward the "some parameters" end of the spectrum and why should one lean toward the "no parameters" end of the spectrum?
I'm asking because methods of the code I'm looking at can potentially find pretty much everything they need on their own, i.e. through member variables. However, I have the feeling that sometimes passing some parameters in would provide useful information about what the method depends upon, improving readability.
Thoughts?
On the other end of the spectrum, a method might require no arguments at all, somehow fetching all it needs through registers, member variables and calling methods of other objects.
In reality, long lists of parameters and the use of output parameters tend to be rare, so that the more commonly used spectrum is somewhere between methods with a few input parameters and methods requiring no parameters.
The question is then: having the choice, why should one lean more toward the "some parameters" end of the spectrum and why should one lean toward the "no parameters" end of the spectrum?
I'm asking because methods of the code I'm looking at can potentially find pretty much everything they need on their own, i.e. through member variables. However, I have the feeling that sometimes passing some parameters in would provide useful information about what the method depends upon, improving readability.
Thoughts?