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 for | Where it shows up | Symptom | Repair evidence |
|---|---|---|---|
| Finishing Strategy and Template Method Lab with only a final answer | Strategy and Template Method Lab | The 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 answer | Observer and Pub/Sub Workshop | The 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 answer | State and Command Clinic | The 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 answer | Code Katas | The 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 tool | Strategy: Encapsulating Interchangeable Algorithms | The 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 tool | Strategy vs Function References and Closures | The 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:
- "I extracted Strategy for the one discount formula we have. Done."
- "The context has
if strategy instanceof FreeShippingto log a special case. It's fine -- it's only one line." - "All our AI bots subclass
GameAI, but each overridesturn()to change the step order." - "Every validator has
validate(input): booland no state; we made each one a class because it feels cleaner." - "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:
- A subject iterates
this.listenersdirectly while calling eachupdate, and a listener callsunsubscribe(self)insideupdate. - A GUI widget registers itself with a model in its constructor and never unsubscribes.
- An
updatemethod calls the subject's setter, which re-entersnotify. - "Two observers must fire in this order; it works now because I added B after A."
- Observer exception bubbles up, subject never notifies the remaining listeners.
State and Command Clinic
Source: practice/03-state-and-command-clinic.md
- "I used State but each state has five fields of its own that carry over to the next state."
- "We have Command but the
execute()also mutates the Command object itself to record results." - "Redo stack was not cleared when the user did a new action; now redo replays into the wrong state."
- "The job queue runs at-least-once and our
SendEmailhandler is not idempotent." - "The order has a
typeenum and five switches; we introduced State pattern ontype, but it never changes."
Repair Protocol
For each real mistake:
- Reproduce the failure on the smallest example, trace, proof, query, command, or design sketch.
- Name the hidden assumption.
- Repair the artifact.
- Save evidence that changed: failing then passing test, corrected proof step, revised diagram, safer command, benchmark, or review note.
- Add one retrieval card beginning with Check... before... or Do not use... when....
Mistake Log
| Date | Mistake | Symptom | Root cause | Repair evidence | Retrieval card |
|---|---|---|---|---|---|
| Starter | Pick one radar row above | Explain how it would fail in this module | Name the assumption | Add a counterexample or corrected artifact | Write 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.