State Pattern

Noun · Development

Definitions

  1. A behavioral design pattern in which an object delegates behavior to interchangeable state objects, each representing a distinct state, so that the object appears to change its class when its internal state changes — eliminating large conditional blocks.

    In plain English: A design technique where an object behaves differently depending on what state it's in, by swapping out the piece of code that handles the behavior.

    Example: "We replaced the giant switch statement in the order class with the state pattern — now Draft, Submitted, and Shipped are each their own class."

Related Terms