Chapter 22. State

The state of an object is a combination of the current values of its attributes. When you call an object's Set- method or assign a value to one of the object's variables or properties, you are changing the object's state. Objects also commonly change their own state as their methods execute.

We sometimes use the word state to refer to a single, changing attribute of an object. For example, we may say that the state of a machine is up or down. In such a case, the changeable part of an object's state may be the most prominent aspect of its behavior. As a result, logic that depends on the object's state may spread through many of the class's methods. Similar or identical logic may appear many times, creating a maintenance burden. ...

Get Design Patterns in C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.