Join the DZone community and get the full member experience.
Join For Free
Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.
The State pattern allows an object to alter its behavior when its internal state changes
- 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.
Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.
Published at DZone with permission
Cristian Chiovari, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.