Talk:Mutator method
![]() | Computer science C‑class Low‑importance | ||||||||||||||||
|
![]() | Computing: Software / CompSci C‑class Low‑importance | ||||||||||||||||||||||
|
- In computer science the mutator method is a method that changes the value of the argument variables.
Wrong, the object the function is called on is changed, not the variables that are passed as argumetns to the method/function
- In the call-by-value form of argument passing, a reference or pointer to the data needs to be passed.
Wrong, no explicit need for that, just because its a mutator. And the example also shows pass-by-value of an integer —Preceding unsigned comment added by 84.176.233.185 (talk • contribs) 09:01, 18 May 2006
C++ example
C++ example is missing usage (main.cpp). — Preceding unsigned comment added by 192.116.217.162 (talk) 10:03, 20 December 2011 (UTC)
Access time
"Accessor functions are always less efficient than directly fetching or storing data fields due to the extra steps involved"
This quote refers to a document from 1998 and is false. For example, the de facto approach to implement accessors in C++ is to write them directly inside the class definition. This causes them to automatically become "inlined" which -when compiled with a modern compiler- will render the exact same access times as if the corresponding class member had been declared "public" and was accessed directly. This contradicts the above claim that accessor functions are always less efficient. As a matter of fact, using a modern compiler accessors in C++ are only less efficient if they are implemented in a separate source file (though I have never seen anybody do this myself). — Preceding unsigned comment added by Kchrdk (talk • contribs) 13:01, 31 July 2012 (UTC)
Getters, Setters and Accessors
Been reading a lot of OO and Smalltalk literature, and it seems to me that the definition of the terms "getter", "setter" and "accessor" given here are wrong. Getter and setter are both right, but "accessor" seems to be used near universally for both setting and getting - i.e. the general term for getter and setter is "accessor".
Class ReadWriteStream is a subclass of WriteStream that represents an accessor that can both read and write elements into its collection.
Goldberg, Adele et. al. Smalltalk-80 The Language and its Implementation (1983) p. 200
For the uninitiated, accessors are methods that let you read and write the value of an instance variable of an object.
https://wiki.c2.com/?AccessorsAreEvil
Accessor methods are used to retrieve and update the values of the state variables
Smalltalk With Style, Edward J. Kilmas & Suzanne Skublics & David A. Thomas, (1996), p. 15
And various parts of writings by Kent Beck.
For a slightly more modern examples, a quick web search of "ruby attr_accessor" will be pretty fruitful.
Gypsydave5 (talk) 14:59, 12 October 2021 (UTC)
Name Change
Suggest renaming this article Accessor method
- The article discusses both getter and setter methods, but the title reflects only setter. Accessor describes both.
- The term 'mutator method' is less popular than both accessor and setter (https://trends.google.com/trends/explore?date=all&q=setter%20method,mutator%20method) (https://books.google.com/ngrams/graph?content=accessor+method%2Cmutator+method&year_start=1980&year_end=2019&corpus=26&smoothing=3#)
- I've never met anyone in my entire career who calls it a mutator method.
- C-Class Computer science articles
- Low-importance Computer science articles
- WikiProject Computer science articles
- C-Class Computing articles
- Low-importance Computing articles
- C-Class software articles
- Low-importance software articles
- C-Class software articles of Low-importance
- All Software articles
- All Computing articles