The State Pattern is a Software Design Pattern like the Observer Pattern that I used during my year in industry in 2020. It is used to implement state specific behaviour, and to control allowed transitions between states.
It is comprised of three parts
- The Context maintains a reference to a concrete state.
- The State Interface allows the context to communicate with concrete states. Only the context may communicate with states.
- The Concrete States are the objects for each state with contain the state-specific methods.