Name for a method that has only side effects

江枫思渺然 提交于 2019-12-10 18:38:28

问题


So, a method that alters its object is a mutator. A method that does not alter its object but returns a value (or reference to a value) is a getter. Is there a widely used name for a method that does not alter its object, does not return a value, but potentially alters objects passed to it as arguments. That is, a method that would only every be called for its side-effects on the arguments.

These methods are quite common if you are keen on the Strategy design pattern.


回答1:


I call these methods operations.

They enable the object to be used as an operator. I don't call them operators however, because I program much C++, where operator method has a particular and different meaning.




回答2:


Is there an widely used name for a method that does not alter its object, does not return a value, but potentially alters objects passed to it as arguments.

The lack of replies suggests that, no, there is no widely used name for such a method.



来源:https://stackoverflow.com/questions/7769816/name-for-a-method-that-has-only-side-effects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!