Skip to main content

Module 3: Behavioral Patterns

Behavioral design means making collaboration predictable under change. Learn all eleven GoF behavioral patterns, choose simpler alternatives when appropriate, and defend ordering, state, failure and ownership with runnable evidence. No pattern count, reading list or module completion establishes a professional percentile.

This guide is the primary teacher; you do not need to read the source books front-to-back. Use Head First Design Patterns for narrative explanations, Design Patterns (GoF) for intent and collaborations, and Refactoring for incremental changes. See the reading guide for exact local locators and honest book-index links.

Prerequisites and entry​

Complete S3 Modules 1–2: callable interfaces, ownership, test doubles, exception traces and bounded behavior-preservation evidence. Start with the prerequisite diagnostic; it tests prior skills, not pattern names you have not learned. Python 3.10+ runs the offline kit. Existing Java/TypeScript snippets are instructional sketches where labeled, not additional toolchain prerequisites.

Learning sequence​

Read the 19 core lessons in order, alternating each cluster with its practice route and lab, then complete the four runtime comparison lessons R1–R4 below. Supporting lessons are part of the concept path; optional reading is separate.

OrderLesson
1Strategy: Encapsulating Interchangeable Algorithms
2Strategy vs Function References and Closures
3Template Method: Fixed Skeleton with Variable Steps
4Observer: Publishing State Changes Without Coupling
5Observer Pitfalls: Re-entrancy, Ordering, Memory Leaks
6Push vs Pull, and the Pub/Sub Generalization
7Command: Making Actions First-Class
8Undo/Redo and Command History
9Command Queues, Logging, and Replayable Systems
10State Pattern: Polymorphic Transitions
11State vs Switch/If Chains: The Refactor Path
12Finite State Machine Modeling in Real Code
13Iterator: Decoupling Traversal from Container
14Chain of Responsibility: Passing Requests Through Handlers
15Visitor and the Double Dispatch Idea
16Memento: Snapshot Ownership and History
17Mediator: Coordination and Feedback
18Interpreter: Small Languages and Resource Bounds
19Protocol Traces and Pattern Composition

Required runtime comparison: R1–R4​

The runtime extension retains the other machine's EventBus/Editor work with explicitly different policies:

OrderLesson
R1Delivery contract
R2Subscription lifecycle
R3No-op and history contract
R4Failure and retry boundaries

Compare both contracts using this table. The combined module therefore has 23 concept lessons, seven core labs and a required two-API comparison package. It does not ask learners to treat incompatible policies as interchangeable implementations of the same API.

The first five clusters cover Strategy/Template Method, Observer, Command, State/FSMs and Iterator/Chain/Visitor. The sixth adds Memento, Mediator, Interpreter and protocol composition. Structural and creational patterns follow in Module 4. Durable messaging, concurrent editors, parser construction and framework-specific reactive streams are later depth work, not claims of these labs.

Practice and evidence path​

  1. Worked examples and behavior contracts.
  2. P01–P05: variation.
  3. P06–P10: notification.
  4. P11–P15: histories and state.
  5. P16–P20: traversal and coordination.
  6. Seven guided labs, three experiments, and the bounded project. Reuse artifacts across tasks.
  7. Independent assessment, then separate feedback and C01–C10 plus BD1–BD6 gates. Practice feedback is separate too.

Outcomes​

Explain change pressure and compare at least one simpler alternative. Make interchangeable policy obey a shared contract. Specify subscription identity, mutation and error behavior. Preserve history on rejected edits. Distinguish commands from accepted facts and local undo from external compensation. Model every state/event cell and failure boundary. Demonstrate lazy traversal, deliberate handler stopping and Visitor's extension tradeoff. Use Mediator and Interpreter only when their coordination/language responsibilities justify them.

Workload and completion​

Required workFocused hours, author estimate
Diagnostic, 19 lessons, targeted reading28–38
20 practice tasks16–24
Seven offline labs24–36
Three experiments8–12
Assessment, repairs, delayed recheck8–12
Project and defense16–23
Core subtotal100–145
Runtime comparison: targeted lessons/traces 3–4, implementation 5–8, assessment/repair 2–410–16
Combined module total110–161

These estimates await learner pilots. At ten focused hours per week the estimate is roughly 11–17 weeks, not a seven-day promise. Count reused evidence once; record actual time and revise estimates. The incoming runtime package's original standalone 18–26-hour estimate becomes 10–16 additional hours here because core instruction and common trace/assessment work are reused. Do the comparison-specific work once; do not add both estimates. Optional depth work adds time.

Completion requires all C01–C10 and BD1–BD6 at level 2 or above, all seven core labs and the runtime comparison package, three experiments, project defense and a 7–14 day delayed recheck. Keep real errors and repairs; do not manufacture a mistake quota. Authored and executed status is separate from independent technical, assessment, accessibility and learner review. See the instructor guide.

Reference and selective reading​

Resources | Reference map | Exercise lanes | Case studies | Mistake clinic