I know the term "pure function" that describes a function whose output is only dependent on the input.
Is there a similar name for a met开发者_JS百科hod (function of an object) whose output is dependent only of the input and the state of the object?
Bertrand Meyer, inventor of the Eiffel programming language and author of the book Object-oriented software construction, calls them "query methods".
I would call it state-dependent method
depending on State
(design-pattern) instance of object is in, you get different result (not only output) or extension
精彩评论