Behavioral Design Patterns
Behavioral patterns define how objects interact and distribute responsibilities. They establish communication protocols, delegate work, and coordinate object behavior—addressing the "what" and "how" of object interaction rather than object structure.
Pattern Family Overview
Categories at a Glance
Chain & Delegation
Distribute responsibility across a chain of handlers or through a mediator coordinating multiple objects.
Command & Execution
Encapsulate actions as objects and manage their execution, undo, and sequencing.
Iteration & Traversal
Define ways to access elements sequentially or traverse complex structures without exposing their implementation.
Observation & Notification
Establish loose coupling through subscriptions, state capture, and event propagation.
State & Behavior
Vary object behavior based on internal state or external strategy without conditional logic.
Specification & Query
Encapsulate business rules and selection criteria as queryable objects.
📄️ Chain of Responsibility Pattern
Pass requests along a chain of handlers, each deciding to process or forward the request
📄️ Command Pattern
Encapsulate a request as an object allowing you to parameterize clients with commands
📄️ Interpreter Pattern
Define a grammar and interpreter for a language to process structured text or commands
📄️ Iterator Pattern
Access elements of a collection sequentially without exposing its underlying representation
📄️ Mediator Pattern
Centralize complex communication logic between multiple objects in a mediator object
📄️ Memento Pattern
Capture and externalize an object's state without violating encapsulation
📄️ Observer / Pub-Sub Pattern
Define a one-to-many dependency where when one object changes state, all dependents are notified
📄️ State Pattern
Allow an object to alter its behavior when its internal state changes
📄️ Strategy Pattern
Define a family of algorithms, encapsulate each, and make them interchangeable
📄️ Template Method Pattern
Define the skeleton of an algorithm, deferring specific steps to subclasses
📄️ Visitor Pattern
Represent an operation to be performed on elements of an object structure
📄️ Null Object Pattern
Provide an object as surrogate for null reference with neutral behavior
📄️ Specification Pattern
Encapsulate business rules as queryable objects for flexible filtering and validation