State Pattern

The State Pattern splits code for state's—distinct modes that an object operates in—out into their own object. It is often useful when an object has many if then statements which all share very similar branching conditions. The state pattern makes the distinct modes more obvious and explicit in how they work, how they differ, and when an objects mode changes.

#pattern #software