Skip to main content

Module 3: Behavioral Patterns: Mistake Clinic

This clinic turns wrong moves into reusable judgment. Use it after each practice page and again before the quiz or checkpoint.


Module-Specific Mistake Radar

Start with these traps. Replace or extend them with real mistakes from your own work.

Mistake to look forWhere it shows upSymptomRepair evidence
Finishing Strategy and Template Method Lab with only a final answerStrategy and Template Method LabThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Observer and Pub/Sub Workshop with only a final answerObserver and Pub/Sub WorkshopThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing State and Command Clinic with only a final answerState and Command ClinicThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Code Katas with only a final answerCode KatasThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Treating Strategy: Encapsulating Interchangeable Algorithms as vocabulary instead of a toolStrategy: Encapsulating Interchangeable AlgorithmsThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.
Treating Strategy vs Function References and Closures as vocabulary instead of a toolStrategy vs Function References and ClosuresThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.

Practice Mistake Checks

Pull any miss from these checks into your mistake log.

Strategy and Template Method Lab

Source: practice/01-strategy-and-template-method-lab.md

Identify the error in each:

  1. "I extracted Strategy for the one discount formula we have. Done."
  2. "The context has if strategy instanceof FreeShipping to log a special case. It's fine -- it's only one line."
  3. "All our AI bots subclass GameAI, but each overrides turn() to change the step order."
  4. "Every validator has validate(input): bool and no state; we made each one a class because it feels cleaner."
  5. "Our sort takes a list of comparator objects. When we need a second-level tie-breaker we add a boolean flag to the interface."

Observer and Pub/Sub Workshop

Source: practice/02-observer-and-pubsub-workshop.md

For each snippet, find the bug:

  1. A subject iterates this.listeners directly while calling each update, and a listener calls unsubscribe(self) inside update.
  2. A GUI widget registers itself with a model in its constructor and never unsubscribes.
  3. An update method calls the subject's setter, which re-enters notify.
  4. "Two observers must fire in this order; it works now because I added B after A."
  5. Observer exception bubbles up, subject never notifies the remaining listeners.

State and Command Clinic

Source: practice/03-state-and-command-clinic.md

  1. "I used State but each state has five fields of its own that carry over to the next state."
  2. "We have Command but the execute() also mutates the Command object itself to record results."
  3. "Redo stack was not cleared when the user did a new action; now redo replays into the wrong state."
  4. "The job queue runs at-least-once and our SendEmail handler is not idempotent."
  5. "The order has a type enum and five switches; we introduced State pattern on type, but it never changes."

Repair Protocol

For each real mistake:

  1. Reproduce the failure on the smallest example, trace, proof, query, command, or design sketch.
  2. Name the hidden assumption.
  3. Repair the artifact.
  4. Save evidence that changed: failing then passing test, corrected proof step, revised diagram, safer command, benchmark, or review note.
  5. Add one retrieval card beginning with Check... before... or Do not use... when....

Mistake Log

DateMistakeSymptomRoot causeRepair evidenceRetrieval card
StarterPick one radar row aboveExplain how it would fail in this moduleName the assumptionAdd a counterexample or corrected artifactWrite the card before closing the page

Completion Standard

  • At least five real mistakes are logged.
  • At least two mistakes include a counterexample or failing test.
  • At least one mistake connects to an older semester skill.
  • At least one correction changes code, a proof, a diagram, a command transcript, a query, or a design decision.