Module 5 / Patterns in practice
Module 5 · Application

Patterns in practice

Identify patterns in real codebases, recognize anti-patterns, and learn to combine patterns effectively.

0/3 lessons

Spotting patterns in real code

Learn

Design patterns aren't academic exercises — they're embedded in the tools you use daily. Recognizing them accelerates learning new frameworks and improves your ability to reason about unfamiliar codebases.

Framework / LibraryPatternWhere
ReactObserveruseEffect dependencies, Context consumers
Express / KoaStrategyMiddleware chain (swappable handlers)
Node.js StreamsIterator + ObserverReadable streams emit data events
Prisma ORMAdapterDatabase driver abstraction layer
AngularDecorator@Component, @Injectable metadata
ReduxCommand + ObserverActions as commands, store.subscribe as observer
When reading framework source code, ask: "What varies here? What stays fixed?" The answer usually reveals the pattern being applied.
Practice
Loading…
Recall0/1
Recall

Redux dispatches actions (objects describing what happened) and notifies subscribers when state changes. Which two patterns does this combine?

Anti-patterns and common misuse

Learn

An anti-pattern is a commonly used solution that appears beneficial but is actually counterproductive. Many anti-patterns arise from misapplying legitimate patterns — using them in the wrong context or taking them too far.

The most dangerous misuse happens when patterns are applied speculatively (before the problem exists) or dogmatically (because a book says so, not because the code demands it).

God Object

A Facade or Singleton that accumulates too many responsibilities. Fix: decompose into focused facades or services.

Cargo Cult Patterns

Applying patterns because they're famous, not because the problem warrants them. Fix: start simple, refactor toward patterns as pain emerges.

Golden Hammer

Treating one pattern as the solution to everything ('everything is a Strategy!'). Fix: evaluate each problem independently.

Lava Flow

Dead code and abandoned patterns left behind after incomplete refactors. Fix: remove dead code aggressively; don't leave half-applied patterns.

The best pattern is often no pattern at all. Complexity should be earned by demonstrated need, not anticipated by theoretical elegance.
Practice
Loading…
Recall0/1
Recall

What is a 'Cargo Cult Pattern'?

Combining patterns

Learn

Production systems rarely use a single pattern in isolation. Effective designs compose patterns to address multiple concerns simultaneously. The skill isn't knowing individual patterns — it's recognizing when and how to combine them.

Common combinations arise naturally: Composite + Iterator (traverse tree structures), Command + Composite (macro commands that group sub-commands), Observer + Strategy (notify observers with pluggable notification strategies), Decorator + Strategy (stack behaviors that delegate to swappable algorithms).

CombinationUse CaseExample
Composite + IteratorTraverse hierarchical structuresFile system browser, org chart renderer
Command + CompositeGroup commands into macrosText editor macro recording, batch operations
Observer + StrategyPluggable notification deliveryAlert system: email, SMS, push via strategy
Decorator + AdapterWrap and adapt simultaneouslyLogging adapter that also adds retry behavior
Factory + StrategyCreate strategies dynamicallyPayment processor selecting strategy by config
Don't plan combinations upfront. Apply one pattern to solve one problem. When a second problem emerges in the same area, ask whether a known combination addresses both cleanly.
Practice
Loading…
Recall0/1
Recall

A text editor supports recording macros (sequences of commands that can be replayed). Which pattern combination makes this possible?