A setter is a method used to control changes to a variable. It's most often used in object-oriented programming, in keeping with the principle of encapsulation.

They are also widely known as mutator methods.

Often a setter is accompanied by a getter (also known as an accessor), 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.

Further details: