Patterns, Anti-Patterns & Diagrams
Some design problems show up so often that proven solutions to them have earned names: design patterns. Their dark mirror — common-looking solutions that reliably cause trouble — are anti-patterns. And teams communicate both using simple diagrams.
You won't drill these here. The goal is to recognize what a pattern is (a shared vocabulary for a recurring solution), what an anti-pattern is (a recurring mistake to avoid), and that a quick sketch usually beats heavy formal notation.
Chess is the easy analogy. Experienced players recognize named openings — well-studied sequences of moves — and play them instantly instead of reinventing each game. Design patterns are named openings for recurring software problems.
Design Patterns
A design pattern is a named, reusable solution to a problem that comes up again and again. It's not code you copy and paste — it's a shape of a solution you adapt to your situation. The real value is the shared vocabulary: when one developer says "let's use an observer here", another instantly pictures the structure, without a long explanation. Patterns let teams discuss design in shorthand.
A Few to Recognize
You don't need to master them, just to have heard the names. A singleton ensures there's only ever one of something (one settings manager for the whole app). A factory is a piece whose job is to create other things, so the rest of the code doesn't have to know the messy details of how. An observer lets parts subscribe to an event and react when it happens. Hearing these names and knowing they're "named, common solutions" is plenty for now.
Anti-Patterns
An anti-pattern is the opposite: a solution that looks reasonable but reliably leads to trouble. Spaghetti code is tangled, jump-everywhere logic with no clear structure. A god object is one giant class that tries to do everything, so it touches the whole system and can't be changed safely. A big ball of mud is a whole system with no discernible architecture. Naming anti-patterns helps teams spot and call out a predictable mess before it sets.
| Pattern (good shape) | Anti-pattern (mess to avoid) |
|---|---|
| Focused modules with clear jobs | God object — one class does everything |
| Clean, traceable flow | Spaghetti code — tangled, jump-everywhere logic |
| A recognizable architecture | Big ball of mud — no structure at all |
Diagrams That Communicate
Designs live in people's heads until they're drawn, so teams sketch them. Most of the time a few boxes and arrows — this part calls that part, data flows this way — communicate more clearly than any formal notation. There's a formal language called UML (Unified Modeling Language) with strict symbols, but in practice a clear, informal sketch on a whiteboard usually wins. The point of a diagram is to be understood, not to be correct in a notation.
On Cadence, when a checked-off habit needs to update the streak, refresh the screen, and maybe fire a reminder, Marcus recognizes the observer pattern — those parts subscribe to the "habit checked off" event and each react on its own. He also dodges an anti-pattern: rather than pile all that logic into one giant "habit manager" class (a god object), he keeps each reaction in its own focused module. A name in each hand — one to reach for, one to avoid.
- "Patterns are code you copy and paste." They're solution shapes you adapt, not snippets to drop in. The value is the shared idea and vocabulary, not literal reused lines.
- "More patterns means better design." Forcing patterns where they aren't needed is itself an anti-pattern. Use one when it genuinely fits the problem, not to look sophisticated.
- "Diagrams must be formal UML to count." A clear boxes-and-arrows sketch usually communicates better than strict notation. The goal is shared understanding, not notational correctness.
- Pattern vocabulary lets developers discuss design in shorthand — a huge part of how teams communicate quickly and precisely.
- Recognizing anti-patterns by name helps you spot a predictable mess early and name it, instead of vaguely sensing something is wrong.
- Knowing that a clear sketch beats heavy notation frees you to communicate designs simply — the diagram's only job is to be understood.
Knowledge Check
What is a design pattern?
- A named, reusable solution shape for a recurring design problem
- A block of code that you copy and paste unchanged straight into your app
- A template for how the app's screens should look
- A common mistake that reliably causes problems
What is an anti-pattern?
- A solution that looks reasonable but reliably causes problems
- A proven, reusable solution to a recurring problem
- A software tool that automatically removes design patterns from your code
- A type of diagram used to document a design
A single giant class tries to do everything in the system and touches every part. What is this?
- A god object — an anti-pattern to avoid
- A well-designed, highly cohesive module
- An observer pattern working as intended
- A factory, whose job is to create other objects
What does the topic say about diagrams?
- A clear boxes-and-arrows sketch usually beats strict formal notation
- A diagram only counts if it uses formal UML notation
- Diagrams are useless and teams should never draw them
- A diagram's single most important job is to be perfectly correct in its notation
You got correct