The State Pattern
The State Pattern
Join the DZone community and get the full member experience.
Join For FreeDelivering modern software? Atomist automates your software delivery experience.
Description:
The State pattern allows an object to alter its behavior when its internal state changes
Benefits:
- Localizes state-specific behavior and partitions behavior for different states
- Makes state transitions explicit
When to use:
- An object’s behavior depends on its state, and it must change its behavior at run-time depending on that state.
- Operations have large, multipart conditional statements thatdepend on the object’s state.
Diagram:
Start automating your delivery right there on your own laptop, today! Get the open source Atomist Software Delivery Machine.
Published at DZone with permission of Cristian Chiovari , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}