Setters (or Mutators)

The flip side of an accessor is a method that is used to set a data field. Such a method is often termed a setter, or sometimes a mutator. Mutators are less common than accessors, but the reasons for using them are similar. They provide better documentation, better control over the way the data field is manipulated (for example, one can perform safety checks before setting a value), and they make it easier to later modify the behavior of the method.

[audio] [real] Text to accompany slide21, in Chapter 4 of An Introduction to Object-Oriented Programming