Objects are said to possess state. The current state of an object is represented by the combined values of its attributes. Protecting the state of an object from inappropriate inspection or modification is an important aspect of class design and we recommend the use of accessor methods and mutator methods to facilitate attribute protection and integrity. The design of a class is often an attempt to model the states of objects in the real-world. Unless there is a good match between the data types available in the language and the states to be modeled, class design may be complex. An important principle in class design is to ensure that an object is never put into an inconsistent state by responding to a message.
Also listed in: