Module 27 ยท Design Patterns (All 23 GoF) โ Lesson 20 of 23 ยท ~6 min
State
Behavior changes with internal state, via legal transitions
State lets an object change its behavior when its internal state changes, moving between states only along allowed edges. A booking goes requested -> confirmed -> in_progress -> completed, or can be cancelled from some states โ but you must never jump from completed back to requested.
The lazy, robust realization is a transitions map: state -> set of allowed next states. Any move not in the map raises.