Book Exercise Lanes
This module's exercise system is book-driven. Use these local chunks for targeted volume after you have already learned the pattern from the guide.
How To Use This Page
- Finish the relevant concept page first.
- Solve at least one kata of your own, from memory, before opening any chunk.
- Only then open the matching exercise lane.
- Keep a mistake log tagged with entries such as
strategy for a one-off function,observer leak on disposal,command with hidden state,switch disguised as states,iterator that exposes internal cursor,handler that forgot to forward.
Lane 1: Variation -- Strategy and Template Method
Use this lane when the main pressure is "one algorithm, many variants" or "fixed skeleton, variable steps".
- HF: Designing the Duck Behaviors
- HF: Integrating the Duck Behaviors
- HF: Testing the Duck Code
- HF: Speaking of Design Patterns
- HF: 8 The Template Method Pattern
- HF: Let's Abstract That Coffee and Tea
- HF: Hooked on Template Method
- GoF: Strategy Sample Code
- GoF: Template Method Implementation
- Refactoring: Replace Conditional with Polymorphism (Part 1)
Target outcomes:
- 1 refactor of a switch-heavy function to Strategy, tests green throughout
- 1 Template Method refactor lifting shared steps with at least one hook
- 2 comparisons where a function reference beat a Strategy object, documented
Lane 2: Notification -- Observer and Pub/Sub
Use this lane when the main pressure is "many readers, one writer" or cross-module event flow.
- 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
- HF: Power Up the Weather Station
- HF: Coding the Life-Changing Application
- GoF: Observer Collaborations
- GoF: Observer Implementation
- GoF: Observer Sample Code
Target outcomes:
- 1 defensive subject handling snapshot, re-entrancy policy, and exception isolation
- 1 pub/sub bus with at least two topic schemas and three subscribers
- 1 documented pitfall each: re-entrancy, subscriber leak, silent failure
Lane 3: Action Encapsulation -- Command, State, FSM
Use this lane when the main pressure is "actions must be recordable / reversible" or "lifecycle with many operations".
- 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: 10 The State Pattern
- HF: Implementing Our State Classes
- HF: The State Pattern Defined
- GoF: Command Implementation
- GoF: State Consequences
- OOAD: FSM -- A Simple Example
- OOAD: Replacing Event Conditionals with Polymorphism
Target outcomes:
- 1 Command-backed feature with undo, redo, and at least 5 command types
- 1 State refactor from a switch-heavy class, with the switches removed
- 1 FSM expressed as a transition table, every cell tested (ignored events included)
Lane 4: Traversal and Flow -- Iterator, Chain of Responsibility, Visitor
Use this lane when the pressure is "client should not know the layout" or "series of handlers / operations over a structure".
- HF: 9 The Iterator and Composite Patterns
- HF: Can We Encapsulate the Iteration?
- HF: Meet Java's Iterable Interface
- HF: Chain of Responsibility
- GoF: Iterator Class and Subclasses
- GoF: Iterator Implementation
- GoF: Iterator Sample Code (Part 1)
- GoF: Chain of Responsibility Implementation
- GoF: Chain of Responsibility Sample Code
- GoF: Chain of Responsibility Known Uses
- GoF: Visitor Applicability
- GoF: Visitor Implementation
Target outcomes:
- 1 tree iterator with two traversal orders, lazy
- 1 CoR with 4+ handlers, order-documented, one test per stop condition
- 1 Visitor with two visitors over the same element hierarchy, noting what growth pattern it favors
Self-Curated Problem Set
Build a custom set with these minimums:
- 2 pattern-selection memos (given a scenario, choose and justify)
- 4 "refactor from switch to pattern" exercises with tests
- 2 "refactor out of pattern" exercises (remove a pattern that no longer earns its weight)
- 1 end-to-end mini system combining at least three patterns (e.g., order lifecycle with Command + State + Observer)
- 1 pitfall reproduction: cause, diagnose, fix, in that order
Completion Checklist
- Completed at least two lanes in full
- Logged at least 10 real mistakes with tags
- Wrote at least 4 pattern-selection memos justifying the pattern chosen
- Reattempted at least 3 failed refactors after review
- One pattern demonstrated in a second language (usually Python ↔ TypeScript or Python ↔ Java)