mutator method

All > Technology > Programming > Java
  • A method specifically designed to allow controlled modification of a private attribute of a class. By convention, we name mutators with a set prefix followed by the name of the attribute being modified. For instance, the mutator for an attribute named speed would be setSpeed. By making an attribute private, we prevent objects of other classes from altering its value other than through its mutator. The mutator is able to check the value being used to modify the attribute and reject the modification if necessary. In addition, modification of one attribute might require others to be modified in order to keep the object in a consistent state. A mutator method can undertake this role. Mutators are used both to grant safe access to the value of a private attribute and to protect attributes from modification by objects of other classes. The latter goal is achieved by choosing an appropriate visibility for the mutator.
    David J. Barnes - Cite This Source - This Definition
  • Browse Related Terms: accessor method, Attribute, State

Browse Nearby Business Terms

MIDP-NG (Next Generation MIDP specification)
MIME
mixed-content model
Mobitex
modal
model-view pattern
Modem
Modulation
module
monitor
MSC (Mobile Switching Center)
multiple-boot options
multiple inheritance
multiprogramming system
multithreaded
mutator method
Mutual Authentication
mutual recursion
Namespace
naming context
naming environment
native
native method
nested class
NEW
new operator
newline
no-arg constructor
non-modal
non-static nested class