Mutator method
In computer science, a mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter (together also known as accessors), which returns the value of the private member variable. In programming languages that support them, properties offer a convenient alternative without giving up the utility of encapsulation. In the examples below, a fully implemented mutator method can also validate the input data or take further action such as triggering an event.
- Comment
- enIn computer science, a mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter (together also known as accessors), which returns the value of the private member variable. In programming languages that support them, properties offer a convenient alternative without giving up the utility of encapsulation. In the examples below, a fully implemented mutator method can also validate the input data or take further action such as triggering an event.
- Has abstract
- enIn computer science, a mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter (together also known as accessors), which returns the value of the private member variable. The mutator method is most often used in object-oriented programming, in keeping with the principle of encapsulation. According to this principle, member variables of a class are made private to hide and protect them from other code, and can only be modified by a public member function (the mutator method), which takes the desired new value as a parameter, optionally validates it, and modifies the private member variable. Mutator methods can be compared to assignment operator overloading but they typically appear at different levels of the object hierarchy. Mutator methods may also be used in non-object-oriented environments. In this case, a reference to the variable to be modified is passed to the mutator, along with the new value. In this scenario, the compiler cannot restrict code from bypassing the mutator method and changing the variable directly. The responsibility falls to the developers to ensure the variable is only modified through the mutator method and not modified directly. In programming languages that support them, properties offer a convenient alternative without giving up the utility of encapsulation. In the examples below, a fully implemented mutator method can also validate the input data or take further action such as triggering an event.
- Hypernym
- Method
- Is primary topic of
- Mutator method
- Label
- enMutator method
- Link from a Wikipage to another Wikipage
- Agile software development
- Assignment (computer science)
- Block (programming)
- Boilerplate code
- Category:Articles with example BASIC code
- Category:Articles with example C++ code
- Category:Articles with example C Sharp code
- Category:Articles with example Java code
- Category:Articles with example Lisp (programming language) code
- Category:Articles with example Pascal code
- Category:Articles with example Perl code
- Category:Articles with example PHP code
- Category:Articles with example Python (programming language) code
- Category:Articles with example Racket code
- Category:Articles with example Ruby code
- Category:Articles with example Smalltalk code
- Category:Method (computer programming)
- Class (computer science)
- Common Lisp Object System
- Computer science
- Cross-validation (statistics)
- C Sharp (programming language)
- D (programming language)
- Data integrity
- Data validation
- Encapsulation (computer science)
- ES6
- Event (computing)
- GNUstep
- Immutable object
- Indexer (programming)
- Information hiding
- Inline function
- Instance variable
- IOS 4
- IOS 6
- Mac OS X 10.6
- Member variable
- Method (computer science)
- Moose (Perl)
- Object-oriented programming
- Operator overloading
- OS X 10.8
- Pointer (computer programming)
- Property (programming)
- Racket (programming language)
- Ruby (programming language)
- Software bug
- Software developer
- Software maintenance
- Ubuntu version history
- Variable (programming)
- Xcode
- SameAs
- 2A9gT
- Kaedah pemutat
- m.0475ph
- Metoda ndryshuese
- Mètode d'actualització
- Mutator method
- Phương thức thay đổi
- Q228491
- Zugriffsfunktion
- Сеттер (программирование)
- 变异子与访问子
- Subject
- Category:Articles with example BASIC code
- Category:Articles with example C++ code
- Category:Articles with example C Sharp code
- Category:Articles with example Java code
- Category:Articles with example Lisp (programming language) code
- Category:Articles with example Pascal code
- Category:Articles with example Perl code
- Category:Articles with example PHP code
- Category:Articles with example Python (programming language) code
- Category:Articles with example Racket code
- Category:Articles with example Ruby code
- Category:Articles with example Smalltalk code
- Category:Method (computer programming)
- WasDerivedFrom
- Mutator method?oldid=1084168338&ns=0
- WikiPageLength
- 24751
- Wikipage page ID
- 1113819
- Wikipage revision ID
- 1084168338
- WikiPageUsesTemplate
- Template:Reflist