When to use

When you need to manage algorithms, responsibilities, and communication between objects while keeping them loosely coupled.

Key traits

Common Scenarios

PatternWhen to Use
๐ŸŽฏ StrategySelecting algorithms at runtime or swapping business logic implementations
๐Ÿ‘๏ธ ObserverEvent-driven systems where multiple objects need to react to state changes
๐Ÿ“‹ CommandEncapsulating requests for undo/redo, queuing, or logging operations
๐Ÿ“ Template MethodDefining algorithm skeleton while letting subclasses override specific steps
๐Ÿ”„ StateChanging object behavior based on its internal state (state machines)
โ›“๏ธ Chain of ResponsibilityProcessing requests through a chain where any handler can process or pass along
๐Ÿ” IteratorAccessing elements of a collection sequentially without exposing its structure
๐Ÿค MediatorCentralizing complex communications and dependencies between objects
๐Ÿšถ VisitorAdding new operations to existing object structures without modifying them
๐Ÿ’พ MementoCapturing and restoring object state for undo/rollback functionality
๐Ÿ“– InterpreterImplementing domain-specific languages or parsing expression grammars