Wrong, the object the function is called on is changed, not the variables that are passed as argumetns to the method/function
| This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
Wrong, the object the function is called on is changed, not the variables that are passed as argumetns to the method/function
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 is missing usage (main.cpp). — Preceding unsigned comment added by 192.116.217.162 (talk) 10:03, 20 December 2011 (UTC)
"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)
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)
Suggest renaming this article Accessor method
Gypsydave5 (talk) 20:30, 12 October 2021 (UTC)
There is no such thing as elaborated upon here. The item as described is a shortcut over 1. safe assignment, 2. conditional assignment, or 3. mere compiler duping to keep its mitts off of direct assignment. It is not necessarily encapsulation, which defines the terms. It's possible to have subsystems that wall themselves off (The X11 subsystems have such a mechanism) complete with mutator-like idioms, but this is not how it's phrased here. Further, it's possible to have an OO implementation of something written in a procedural (only) language, but then we're back to OO encapsulation which again drives the proper definition of the term.
𝓦𝓲𝓴𝓲𝓹𝓮𝓭𝓲𝓪𝓘𝓼𝓝𝓸𝓽𝓟𝓮𝓮𝓻𝓡𝓮𝓿𝓲𝓮𝔀𝓮𝓭-𝓟𝓮𝓮𝓻𝓡𝓮𝓿𝓲𝓮𝔀𝓮𝓭𝓜𝓮𝓪𝓷𝓼𝓡𝓮𝓿𝓲𝓮𝔀𝓮𝓭𝓑𝔂𝓟𝓮𝓮𝓻𝓼𝓞𝓷𝓵𝔂 (talk) 21:21, 22 December 2021 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.