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.
Head First Design Patterns is not a pattern encyclopedia — it is a course in the design principles that make patterns necessary. Every chapter starts from a concrete, slightly absurd product scenario (a duck simulator, a weather station, a coffee shop menu), lets the naive design fail, and then derives the pattern as the fix. Along the way it hammers a small set of principles: encapsulate what varies, favor composition over inheritance, program to interfaces, and strive for loose coupling between objects that interact.
The Head First format — sketches, redundant explanations, quizzes, crossword puzzles — looks unserious and is precisely why the material sticks. The authors apply cognitive science deliberately: the same idea arrives through pictures, code, conversation, and exercises until it survives contact with your actual codebase.
Developers who can already write working code in an object-oriented language and want to make design decisions on purpose instead of by habit. If you have ever inherited a wall of if/else branches, watched a subclass tree explode, or wired a change through nine files that should have taken one — this book names the problem you had and shows the standard repair.
It is not for absolute beginners (learn a language first) and it is not a reference manual — for that, keep the Gang of Four book nearby. Head First is the book that makes the reference manual readable.
Original collection
Each page below is our original visual-logic treatment of one pattern from the book — a PROBLEM → RULE → RUN → OUTPUT flow, a TypeScript example, and 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.
Yes. The second edition (2020) updates the code to Java 8+ and the concepts — encapsulating what varies, composition over inheritance, programming to interfaces — are language-agnostic and unchanged since the Gang of Four. It remains the most approachable serious introduction to design patterns.
The examples are in Java, but they use a small, readable subset. If you can follow classes and interfaces in any typed language, you can follow the book. Our pattern pages translate the same ideas into TypeScript if that is closer to your daily stack.
The second edition modernizes the Java (lambdas, newer collections), refreshes examples, and fixes errata, while keeping the same fourteen patterns and teaching style. If you are buying new, get the second edition.
Head First first. The Gang of Four book (Design Patterns, 1994) is the reference catalog — precise but dense. Head First teaches you why each pattern exists; GoF is what you consult afterward when you need the formal treatment.
Our pages give you the logic; the book gives you the full derivations, the design principles, and four more patterns we have not covered yet.