Reference and Selective Reading
You do not need to read the source books front-to-back for this module. Use the concept pages and practice pages first. Open these local chunks only when you need alternate exposition, more worked examples, or a deeper exercise lane.
Source Roles
| Source | Role | Why it is here |
|---|---|---|
| Head First Design Patterns | Primary narrative | Best on-ramp for every pattern in this module. Tone is informal; pedagogy is strong |
| Design Patterns (GoF) | Canonical vocabulary | Precise intent, participants, collaborations, and "known uses". Terse and authoritative |
| Refactoring (Fowler) | Refactor moves | Use when a pattern is the endpoint of a refactor, not a greenfield design |
| Clean Code (Martin) | Readability | Use to resist over-patterning and to see switches as a code quality issue |
| Good Code, Bad Code (Hansen) | Engineering judgment | Use for cost/benefit arguments on pattern adoption |
| OOAD | FSM modeling | Use specifically when the State cluster needs deeper structural backing |
Read Only If Stuck
Cluster 1: Strategy and Polymorphic Variation
- HF: Designing the Duck Behaviors
- HF: Integrating the Duck Behaviors
- HF: Testing the Duck Code
- HF: Speaking of Design Patterns
- HF: Overheard in the Next Cubicle
- HF: Tools for Your Design Toolbox (Strategy)
- HF: Exploring Strategy (MVC)
- HF: 8 The Template Method Pattern
- HF: Let's Abstract That Coffee and Tea
- HF: Template Method Pattern Defined
- HF: Hooked on Template Method
- HF: Template Methods in the Wild
- GoF: Strategy Applicability
- GoF: Strategy Sample Code
- GoF: Strategy Known Uses
- GoF: Template Method Implementation
- Refactoring: Replace Conditional with Polymorphism (Part 1)
- Refactoring: Replace Conditional with Polymorphism (Part 2)
- Refactoring: Replace Type Code with Subclasses
Cluster 2: Observer and Event Notification
- HF: The Observer Pattern
- HF: Publishers + Subscribers = Observer Pattern
- HF: Observer Pattern Class Diagram
- HF: The Power of Loose Coupling
- HF: Implementing the Subject Interface in WeatherData
- HF: Power Up the Weather Station
- HF: Coding the Life-Changing Application
- HF: Tools for Your Design Toolbox (Observer)
- GoF: Observer Collaborations
- GoF: Observer Implementation
- GoF: Observer Sample Code
- Good Code Bad Code: Invalid States
Cluster 3: Command and Action Encapsulation
- HF: 6 The Command Pattern
- HF: The Command Pattern Defined
- HF: Assigning Commands to Slots
- HF: More Uses of the Command Pattern -- Logging Requests
- HF: Memento (Leftover Patterns)
- GoF: Command Class and Subclasses
- GoF: Command Implementation
- GoF: Command Known Uses
- Refactoring: Replace Function with Command
- Refactoring: Replace Command with Function
Cluster 4: State and Behavior-Switching Patterns
- HF: 10 The State Pattern
- HF: The New Design
- HF: Implementing Our State Classes
- HF: Implementing More States
- HF: The State Pattern Defined
- GoF: State Consequences
- GoF: State Known Uses
- OOAD: FSM -- A Simple Example
- OOAD: Requirements Analysis with FSMs
- OOAD: Transitioning Between States
- OOAD: State Classes to Observer Pattern
- OOAD: Replacing Event Conditionals with Polymorphism
- OOAD: Features of the State Pattern to Consequence
- Refactoring: Decompose Conditional
- Refactoring: Replace Conditional with Polymorphism (Part 1)
- Refactoring: Replace Conditional with Polymorphism (Part 2)
- Refactoring: Repeated Switches
- Clean Code: Switch Statements
Cluster 5: Traversal and Processing Patterns
- HF: 9 The Iterator and Composite Patterns
- HF: What's the Problem with Two Menu Representations?
- HF: Can We Encapsulate the Iteration?
- HF: The Single Responsibility Principle
- HF: Meet Java's Iterable Interface
- HF: Writing the Enumeration/Iterator Adapter
- HF: Chain of Responsibility
- GoF: Encapsulating Access and Traversal
- GoF: Iterator Class and Subclasses
- GoF: Encapsulating the Analysis (Visitor motivation)
- GoF: Visitor Class and Subclasses
- GoF: 5 Behavioral Patterns (intro)
- GoF: Chain of Responsibility Implementation
- GoF: Chain of Responsibility Sample Code
- GoF: Chain of Responsibility Known Uses
- GoF: Iterator Implementation
- GoF: Iterator Sample Code (Part 1)
- GoF: Iterator Sample Code (Part 2)
- GoF: Iterator Known Uses
- GoF: Visitor Applicability
- GoF: Visitor Implementation
- GoF: Visitor Sample Code
Optional Deep Dive
- HF: King of Compound Patterns (MVC)
- HF: Using MVC to Control the Beat
- HF: Better Living with Patterns
- HF: Organizing Design Patterns
- GoF: Designing for Change (Part 1)
- GoF: How to Select a Design Pattern
- GoF: Objects as Arguments (Command/Visitor connection)
- GoF: Decoupling Senders and Receivers
- Refactoring: Code Smells -- Alternative Classes with Different Interfaces
Concept-to-Source Map
| Primary concept | Best source if stuck | Why this source |
|---|---|---|
| Strategy: encapsulating interchangeable algorithms | HF: Integrating the Duck Behaviors | Refactor-driven derivation of the pattern |
| Strategy vs function references and closures | GoF: Strategy Applicability | Explicit trade-offs and when not to pattern |
| Template Method: fixed skeleton with variable steps | HF: Template Method Pattern Defined | Clean definition and hook discussion |
| Observer: publishing state changes without coupling | HF: The Power of Loose Coupling | Best statement of the dependency direction |
| Observer pitfalls | GoF: Observer Implementation | Discusses update protocols and lapsed-listener problems |
| Push vs pull and Pub/Sub | GoF: Observer Collaborations | Precise vocabulary for both |
| Command: making actions first-class | HF: The Command Pattern Defined | Sharp role definitions |
| Undo/redo and command history | GoF: Command Implementation | Concrete undo discussion |
| Command queues, logging, replay | HF: Logging Requests | Shortest path to the replay mental model |
| State pattern | HF: The State Pattern Defined | Direct and short |
| State vs switch/if chains | Refactoring: Replace Conditional with Polymorphism (Part 1) | The mechanical move |
| FSM modeling | OOAD: FSM -- A Simple Example | Explicit state/event/transition framing |
| Iterator | HF: Can We Encapsulate the Iteration? | The extraction move |
| Chain of Responsibility | GoF: Chain of Responsibility Implementation | Implementation choices and stop conditions |
| Visitor and double dispatch | GoF: Visitor Implementation | Most direct treatment of the double-dispatch idea |