Strategy
When one task has several valid ways to run, Strategy keeps the workflow stable while the decision-making rule can change independently.
Book 01 · Second Edition
A practical guide to reusable object-oriented design. Everyday as Code uses it as a source, then adds original simulations, trade-offs, and real-world examples.
Retail links are not affiliate links yet. If that changes, this page will clearly disclose it.
Original collection
Each page explains one pattern with a new example and includes the condition where the abstraction becomes a bad trade.
When one task has several valid ways to run, Strategy keeps the workflow stable while the decision-making rule can change independently.
Observer turns a state change into a broadcast so multiple dependents can react without the source knowing their concrete implementations.
Decorator wraps an object with optional layers, allowing capabilities to be combined at runtime without creating a subclass for every combination.
Factory Method separates object creation from the workflow that uses the object, allowing a subtype or configuration to choose the concrete product.
Singleton guarantees one globally reachable instance, but the convenience behaves like shared global state and must be treated as a trade-off.
Command packages a request as an object so actions can be queued, logged, retried, composed, or reversed independently from the caller.
Adapter converts an existing interface into the interface a client expects, containing incompatibility at one explicit system boundary.
Facade offers a small task-oriented interface over a complicated subsystem, reducing the knowledge each caller needs for common workflows.
Template Method defines a stable algorithm sequence while allowing selected steps to vary through subclass hooks or overrides.
Iterator provides a standard way to traverse a collection while hiding whether the underlying structure is an array, tree, stream, or remote page.