Skip to main content

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. The goal is fluency and judgment, not completion.

How To Use This Page

  1. Finish the relevant concept page first and do at least one kata from the Practice section.
  2. Only then open the matching exercise lane.
  3. Work one lane before moving to the next.
  4. Keep a mistake log with tags such as cargo-culted factory, adapter leaks adaptee types, decorator hides behavior, proxy confused with decorator, singleton hides scope, new in domain service, or config read outside boundary.

Lane 1: Creational Construction

Use this lane when the pain is construction complexity, variation of concrete types, or immutability discipline.

Target outcomes:

  • 3 factory-method implementations, each with at least two concrete creators
  • 1 abstract-factory implementation with two product kinds and two families
  • 1 fluent Builder with invariants enforced in build()
  • 1 deletion refactor: a cargo-culted factory removed and replaced with a direct constructor call

Lane 2: Interface Bridging

Use this lane when the pain is integration with third-party or legacy code, or subsystem complexity.

Target outcomes:

  • 2 adapters against real third-party libraries, each with at least one exception mapping
  • 1 facade over a subsystem you use regularly, covering the common 80% case
  • 1 written paragraph distinguishing Adapter from Facade using your own example
  • 1 Bridge sketch (may remain a sketch) with a written defense of whether you would actually build it

Lane 3: Composition and Layering

Use this lane when the pain is behavior layering, tree operations, or controlled access.

Target outcomes:

  • 1 Composite over a real tree structure (menu, file system, widget tree)
  • 1 Decorator pipeline with at least three layers wrapping a real interface
  • 1 virtual or caching Proxy over a slow resource
  • 1 written paragraph distinguishing Decorator from Proxy by intent

Lane 4: Pragmatic Selection and DI

Use this lane when you have the vocabulary but need to build judgment: when to apply, when to delete, and how to wire.

Target outcomes:

  • 4 design briefs: pick the right pattern for a given scenario, with written justification
  • 2 "delete a pattern" refactors with before/after diffs
  • 1 composition root for a small app with at least three injected infrastructure collaborators
  • 1 test composition root that swaps in fakes
  • 1 written memo on DI vs service locator referencing one example from your own code

Self-Curated Problem Set

Build a custom set with these minimums:

  • 3 creational implementations (Factory Method, Abstract Factory, Builder -- one each)
  • 3 structural implementations (Adapter, Facade, and one of Decorator/Proxy/Composite)
  • 2 pattern-deletion refactors where the pattern was cargo-culted
  • 2 "collapse to function" refactors in a language with first-class functions
  • 1 small application wired through a composition root

Completion Checklist

  • Completed at least one lane in full
  • Logged at least 10 real pattern misuses and corrections
  • Wrote at least 8 design briefs in sentence form (force -> category -> pattern)
  • Deleted at least one cargo-culted pattern from real code
  • Built at least one composition root and defended its boundaries
  • Can argue both sides of "should we introduce a pattern here" for at least three scenarios