State (objects for states)Pattern
Summary
Allow an object to alter its behavior when it’s internal state changes. The object will appear to change its class.
This is a clean way for an object to partially change its type at run-time
An object-oriented state machine
wrapper + polymorphic wrappee + collaboration
Overview Tutorial
Example
Cursor changes it shape based on underlying context
Specific Consideration
Strategy VS State Pattern
Both strategy and state looks same from class diagram prospective but intent is deferent
Strategy defines class behavior at initialization time while state pattern changes the behaviors any time during the object life cycle bases on object internal state
In strategy client binds behavior with class but in strategy object itself reload it behavior based on its internal state.