Vasu Patel logoVasu Patel
← Patterns of Good Design
All chapters in this track
  1. 01Chapter 1: Why Patterns Exist — Vocabulary, Not a Checklist
  2. 02Chapter 2: Patterns and SOLID: How They Relate
  3. 03Chapter 3: Creational Patterns I: Factory Method & Abstract Factory
  4. 04Chapter 4: Creational Patterns II: Builder, Singleton, Prototype
  5. 05Chapter 5: Structural Patterns I: Adapter & Facade
  6. 06Chapter 6: Structural Patterns II: Decorator & Proxy
  7. 07Chapter 7: Structural Patterns III: Composite, Bridge & Flyweight
  8. 08Chapter 8: Behavioral Patterns I: Strategy & Template Method
  9. 09Chapter 9: Behavioral Patterns II: Observer & Mediator
  10. 10Chapter 10: Behavioral Patterns III: Command & Memento
  11. 11Chapter 11: Behavioral Patterns IV: State & Chain of Responsibility
  12. 12Chapter 12: Behavioral Patterns V: Iterator & Visitor
  13. 13Chapter 13: Anti-Patterns and Overuse: Recognizing "Pattern Fever"
  14. 14Chapter 14: How Dynamic and Functional Languages Solve These Problems Differently
  15. 15Chapter 15: Architectural Patterns I: MVC/MVVM & Layered/Hexagonal Architecture
  16. 16Chapter 16: Architectural Patterns II: Event-Driven Architecture & CQRS
  17. 17Chapter 17: Architectural Patterns III: The Repository Pattern
  18. 18Chapter 18: Recognizing Which Pattern Fits an Interview Design Prompt

Chapter 1 of 18

Chapter 1: Why Patterns Exist — Vocabulary, Not a Checklist

Why this matters

Design patterns have an image problem: they're taught as a catalog to memorize, which produces engineers who reach for a pattern because they recognize its shape, not because the problem in front of them actually needs it. This is the single most damaging misconception this book will spend its whole length correcting. Patterns are a shared vocabulary for solutions that recur, not a checklist of things a "good" design must include.

The core concept

[BEGINNER] A design pattern is a named, reusable solution to a problem that recurs across many unrelated codebases — not a specific piece of code you copy, but a shape of solution you adapt to your situation. The value of naming these shapes is almost entirely in communication: saying "let's use a Strategy here" conveys, in three words, an entire design (an interface, multiple implementations, a caller that's decoupled from which one is active) that would otherwise take a paragraph to describe from scratch every time.

This origin matters because it explains what patterns are for: they emerged from engineers noticing the same well-shaped solution appearing independently, again and again, in different systems — not from a committee designing structures for engineers to apply. The 1994 "Gang of Four" book (Design Patterns: Elements of Reusable Object-Oriented Software) catalogued 23 of these recurring shapes, observed in real production object-oriented systems of the time, and gave each one a name.

The problem this solves, concretely — before patterns had names, this conversation happened constantly:

"So I need one object that decides how to do X, but I want to be able to swap out how it decides without changing the code that calls it, and I want each way of deciding to be its own self-contained thing, and—" "You mean a Strategy." "...yes."

That's the entire value proposition. A pattern name compresses a whole design into a word both engineers already understand, the same way "binary search" compresses an entire algorithm into two words in an algorithms conversation.

Patterns are not a checklist

[SENIOR INSIGHT] The most important sentence in this book might be this one: a good design that happens to use zero named patterns is a better outcome than a mediocre design that uses five. Patterns describe recurring good solutions to problems that actually occur — they are not virtue in themselves, and forcing one onto a problem that doesn't have the shape the pattern solves adds complexity with no offsetting benefit. This failure mode has its own name — "pattern fever" — and gets a full chapter (Chapter 13) because it's common enough among engineers who've just learned patterns to warrant explicit treatment.

A useful discipline for every chapter in this book: for every pattern, you'll see the problem it solves, stated first, before the pattern itself. If you can't state a concrete problem your current code has, the pattern isn't earning its place yet — this is the single check that prevents pattern fever before it starts.

The four categories, and why they exist

[BEGINNER] The Gang of Four organized patterns into three categories by what kind of problem they solve; this book adds a fourth, architectural, covering patterns that operate at the level of whole-application structure rather than a handful of collaborating classes:

CategoryAnswers the questionExamples in this book
Creational"How should this object get created?"Factory Method, Abstract Factory, Builder, Singleton, Prototype
Structural"How should these objects be composed/related?"Adapter, Facade, Decorator, Proxy, Composite, Bridge, Flyweight
Behavioral"How should these objects communicate and share responsibility?"Strategy, Observer, Command, State, Template Method, Chain of Responsibility, Iterator, Mediator, Visitor, Memento
Architectural"How should the whole application be structured?"MVC/MVVM, layered/hexagonal architecture, event-driven architecture, CQRS, repository pattern

Knowing the category a problem falls into is itself useful triage: "I need to control how this gets constructed" points you toward creational patterns before you've even picked a specific one; "I need to change what happens when a request arrives, without the caller knowing" points toward behavioral patterns.

Common mistakes

  1. Learning patterns by memorizing their class diagrams instead of the problem each one solves. This produces exactly the pattern-fever failure mode — a candidate or engineer who spots "objects that need to vary independently" and immediately reaches for Bridge, without asking whether a much simpler solution exists.
  2. Assuming a pattern's textbook implementation must be followed exactly. Real code almost always adapts a pattern's shape to the situation (fewer classes, language-specific idioms) — the shape of the solution is what's being reused, not a literal template.
  3. Treating "this codebase doesn't use recognizable patterns" as evidence of poor design. Plenty of good code solves its problems directly, with no named pattern's shape appearing anywhere, because the code's problems don't happen to be shaped like any catalogued recurring problem.
  4. Not being able to state the problem a pattern in your own code solves. If you inherited a Factory class and can't say why it exists, that's worth investigating — either the reason has been forgotten and should be documented, or the pattern was never justified and adds cost with no benefit.

Checklist: using pattern vocabulary well

  1. State the problem before naming the pattern, in every design discussion and in every chapter of this book — "I need X, independent of Y" before "so I'll use a Strategy."
  2. Use pattern names as compression for communication, not as goals. "Let's use Observer here" should mean "here's a well-understood shape for what we need," not "we should have an Observer in this system."
  3. When you inherit code using a named pattern, find the original problem it solved before changing or removing it — sometimes it's solving a real, non-obvious problem; sometimes it's vestigial.
  4. Don't feel obligated to reach for a catalogued pattern when a simpler, unnamed solution fits just as well. Not every recurring shape in your code needs to map onto the Gang of Four's catalog.

Discussion / interview questions

  1. "What is a design pattern, in your own words?" Strong answer: A named, reusable shape of solution to a problem that recurs across codebases — valuable primarily as shared vocabulary for communicating a design quickly, not as a mandatory ingredient of good code.

  2. "Why is 'using more design patterns' not the same as 'better design'?" Strong answer: Patterns solve specific, real problems; applying one where the corresponding problem doesn't exist adds indirection and ceremony with no offsetting benefit — cites "pattern fever" as the named failure mode.

  3. "How would you decide whether a design problem calls for a creational, structural, or behavioral pattern?" Strong answer: Frames it by the question being asked — "how should this be created," "how should these be composed," or "how should these communicate" — as a triage step before considering specific patterns.

  4. "You inherit a class named WidgetFactory and can't tell why it's not just a constructor. What would you do?" Strong answer: Investigate the original reasoning (git history, tests, related code) before removing or changing it — it might solve a real, non-obvious problem (e.g., an Abstract Factory need from Chapter 3), or it might be unjustified ceremony worth simplifying.

  5. "Where did design patterns as a concept come from, and why does that origin matter?" Strong answer: They were observed as recurring solutions across real production object-oriented systems (catalogued by the "Gang of Four" in 1994), not designed top-down — which is why the correct usage model is "recognize a recurring problem, reach for a known solution shape," not "pick a pattern and force a problem to fit it."

Chapter summary / cheat sheet

  • A pattern is a named, reusable shape of solution to a recurring problem — its main value is as shared vocabulary for design communication.
  • Patterns are not a checklist or a virtue in themselves; a good pattern-free design beats a mediocre design stuffed with unjustified patterns.
  • Always state the problem before naming the pattern — if you can't state a concrete problem, the pattern doesn't belong yet.
  • Four categories in this book: creational (how it's created), structural (how things are composed), behavioral (how things communicate), architectural (how the whole application is structured).
  • "Pattern fever" — reaching for a pattern because you recognize its shape rather than because the problem needs it — is a real, common, and named failure mode (fully covered in Chapter 13).