Conceptual
Login

State Pattern implementation in Python document editing and game logic examples

The State pattern is a behavioral design pattern that lets an object change its behavior by changing its current state, with each state's specific behavior encapsulated in its own state object rather than in the owning object. It decouples the object that has a state (the context) from the behavior tied to each state, via a common state interface that every concrete state implements, and so prevents a single class from accumulating too many responsibilities. It belongs to object-oriented software design, within the family of behavioral design patterns, and is closely tied to finite-state-machine thinking.