O'Reilly logo

Design Patterns in C# by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required