开发者

Name for a method that has only side effects

开发者 https://www.devze.com 2023-04-12 21:14 出处:网络
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

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号