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.