The State pattern allows an object to alter its behavior when its internal state changes. The object appears to change its class.
The Figure illustrates the State Pattern.
The following lists the benefits of using the State pattern:
- Localizes state-specific behavior and partitions behavior for different states .
- Make state transitions explicit.