Join the DZone community and get the full member experience.
Join For Free
Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.
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.
The Java Zone is brought to you in partnership with JetBrains. Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.
Published at DZone with permission of
, DZone MVB
Opinions expressed by DZone contributors are their own.