13 The State Design Pattern

This chapter covers

  • The State Design Pattern

Chapter 12 showed how the Observer Design Pattern provides a model for an application where the subject object (the publisher) plays a key role in the operation of the application by supplying content data for the observer objects (the subscribers). In this chapter, an object also plays a key role. We must monitor the runtime state changes of this object because its behavior is critical to the operation of the application.

As we saw in section 4.5, events that change the values of the object’s member variables can cause an object to make a transition from one state to another. The object can behave differently according to its current state. The State Design Pattern provides ...

Get Object-Oriented Software Design in C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.