State

E173619

State is a behavioral design pattern that lets an object alter its behavior when its internal state changes, making it appear as if the object has changed its class.

All labels observed (2)

Label Occurrences
State canonical 1
State pattern 1

How this entity was disambiguated

Statements (48)

Predicate Object
instanceOf behavioral design pattern
alsoKnownAs State
surface form: State pattern
alters object behavior based on internal state
appliesWhen object behavior depends on its state
operations have large conditional statements that depend on object state
benefit improves code maintainability
localizes state-specific behavior
simplifies adding new states
canBeImplementedWith abstract classes
interfaces
category object-oriented design pattern
commonExample TCP connection states
UI widget states
document lifecycle states
contextHolds reference to a State object
defines separate state objects
describedIn Design Patterns: Elements of Reusable Object-Oriented Software
differsFrom Strategy (design pattern) by modeling intrinsic states rather than interchangeable algorithms
effect makes object appear to change its class
encapsulates state transitions
state-specific behavior
firstPublished 1994
intent allow an object to alter its behavior when its internal state changes
languageAgnostic true
originatedBy Erich Gamma
John Vlissides
Ralph Johnson NERFINISHED
Richard Helm
participants ConcreteState
Context
State interface
partOf Gang of Four design patterns
reduces complex conditional statements
relatedTo Strategy (design pattern)
separates state-specific logic from context object
stateObject implements behavior associated with a particular state
supports finite state machine modeling
Open-Closed Principle
surface form: open/closed principle

runtime state transitions
tradeoff increases number of classes
typicalConcreteStateResponsibility implement behavior for a particular state
typicalContextClassResponsibility delegate requests to current state object
maintain current state
typicalStateInterfaceResponsibility declare state-specific operations
usedFor removing state-dependent conditionals from client code
usedIn object-oriented programming
uses composition
delegation

How these facts were elicited

Referenced by (2)

Full triples — surface form annotated when it differs from this entity's canonical label.

State alsoKnownAs State
subject surface form: State (design pattern)
this entity surface form: State pattern