Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
State pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Software design pattern}} The '''state pattern''' is a [[Behavioral pattern|behavioral]] [[software design pattern]] that allows an object to alter its behavior when its internal state changes. This pattern is close to the concept of [[finite-state machine]]s. The state pattern can be interpreted as a [[strategy pattern]], which is able to switch a strategy through invocations of methods defined in the pattern's interface. The state pattern is used in [[computer programming]] to encapsulate varying behavior for the same [[object (computer science)|object]], based on its internal state. This can be a cleaner way for an object to change its behavior at runtime without resorting to conditional statements and thus improve maintainability.<ref name="GOF">{{cite book |author=[[Erich Gamma]] |author2=[[Richard Helm]] |author3=[[Ralph Johnson (computer scientist)|Ralph Johnson]] |author4=[[John M. Vlissides]] |title=Design Patterns: Elements of Reusable Object-Oriented Software |publisher=[[Addison-Wesley]] |year=1995 |isbn=0-201-63361-2|title-link=Design Patterns: Elements of Reusable Object-Oriented Software }}</ref>{{Rp|395}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)