- When the state inside an object changes, it can change its behavior by switching to a set of different operations
- The Context represents information that is mostly fixed, whereas the State can change between the available options as the program progresses
- The State pattern relies on simple mechanisms: interfaces and aggregation.
- The States can be classes, or if they are quite simple—without much data— they can be implemented as delegates.
- Context: A class that maintains an instance of a State that defines the current context and the interface of interest to clients
- IState: Defines an interface for a particular state of the Context
- The State has full access to the data in the Context.
- At any point, either the Context or the active State can decide that it is time to switch states.
- StateA and StateB: Classes that implement behavior associated with a state of the Context