December 2017
Intermediate to advanced
468 pages
13h 12m
English
These allow an object to alter its behavior when its internal state changes, and it appears as the class changes.
Use state pattern when an object's behavior depends on its state and change at runtime depends on that state.

The diagram depicts both structure of State pattern and a sample implementation; Context class carries states, and Off and On classes implement State interface so that context can use the action on each concrete class's off/on.
Listed are the benefits:
Read now
Unlock full access