NOTE
State Pattern
Representing state-dependent behavior with explicit state objects instead of sprawling conditionals.
This is a historical learning note and may contain outdated or incomplete understanding.
The State pattern encapsulates behavior that changes with an object’s state into separate state representations. Transitions can then be explicit rather than spread across many if/switch statements.
Use it when state-dependent behavior is substantial. For a small finite state machine, an enum plus an explicit transition table may be simpler and easier to verify.