Skip to main content

Instructor Notes

SENG 365 — classroom companion

Author
Affiliation

Neil Ernst

University of Victoria

Published

December 1, 2026

After slide: Entry Decision (Decorator and Command) — discussion notes

Source: lectures/M6.qmd → “Decorator and Command” → “Entry Decision”

With n independent toppings, subclass-per-combination approaches can require up to 2^n variants. A flags class avoids that class explosion but concentrates combination logic in conditionals and couples each new option to the same implementation. Decorators allow additions to be composed one at a time. A simple list of data-driven additions may still be clearer when each option only changes price and description and has no distinct behaviour or interaction; ask what kind of change the design needs to absorb.

After slide: Decorator Studio — facilitation notes

Source: lectures/M6.qmd → “Decorator and Command” → “Decorator Studio”

Have students draw a basic Beverage wrapped by two decorators, each implementing the same interface and storing the beverage it wraps. cost() delegates and adds the decorator’s price; description() delegates and appends its label. The object graph should make the order of wrappers visible. Compare this with a list of additions: prefer the list when additions are independent data; the decorator earns its indirection when additions have distinct behaviour, can be composed flexibly, or should be added without changing existing beverage classes.

UML class diagram for the decorator example. Both concrete decorators are beverages and each wraps one beverage.

PlantUML source

UML object diagram: the client holds an outer WhippedCream object, which wraps VanillaSyrup, which wraps the base Espresso beverage.

PlantUML source

After slide: Command Studio — facilitation notes

Source: lectures/M6.qmd → “Decorator and Command” → “Command Studio”

A useful design has a Command.execute() operation, a concrete command holding its target (for example, an editor or document) and the arguments needed later, and a history owned by the application or editor. Add undo() only when the action has a meaningful inverse or can retain the state needed to restore the previous result; some actions need a snapshot or memento. Define failure behavior: do not add a failed command to undo history, and avoid leaving a partially applied edit where possible. A lambda is lighter for an immediate, one-off callback; a named command earns its cost when the action needs identity, stored arguments, history, replay, logging, queueing, or undo.

The slide starts with a direct undo call. If the application needs an undo history, the UI can ask the history to undo its latest command. This object diagram shows one possible state after an insert command has run: the history retains the command, and the command retains its editor target and captured arguments.

UML object diagram for Command: command history holds an executed insert command, which links to its editor target and stores its text and position.

PlantUML source

After slide: Exit Note (Decorator and Command) — model answer

Source: lectures/M6.qmd → “Decorator and Command” → “Exit Note”

Decorator is heavier than the problem deserves when a few stable options are simple data and a list can represent them clearly. Command is heavier when an action is immediate and needs no queue, history, replay, logging, or undo. Look for the student to name the extra indirection and the absent design pressure.

After slide: Entry Decision (Sequence Diagrams and Demeter) — model answer

Source: lectures/M6.qmd → “Sequence Diagrams and Demeter” → “Entry Decision”

The client knows that Foundations contains a Pile, that the pile exposes its card collection, and that the collection can be mutated directly. A domain operation such as foundations.addTo(FIRST, card) can keep selection and mutation behind the foundation API, where validation can live. The chain is concerning because it exposes internal structure and lets the client bypass the pile’s own rules, not simply because the line has several dots.

After slide: Follow the Run-Time Collaboration — facilitation notes

Source: lectures/M6.qmd → “Sequence Diagrams and Demeter” → “Follow the Run-Time Collaboration”

The diagram should show the client sending getPile(FIRST) to foundations, receiving a pile, sending getCards() to it, receiving a collection, and sending add(card) to that collection. Mark the returned objects as the source of the next dependency: the client must know the representations of both the foundation and pile. The final collection mutation also bypasses any domain validation in Pile or Foundations. Sequence diagrams reveal this run-time path and the returned references; a class diagram alone usually does not show that call order.

After slide: Exit Note (Sequence Diagrams and Demeter) — model answer

Source: lectures/M6.qmd → “Sequence Diagrams and Demeter” → “Exit Note”

One answer is: “The chain foundations.getPile(FIRST).getCards().add(card) is problematic because the client traverses and mutates internal objects, so changes to the pile or collection representation ripple into it.” Accept “acceptable” when a student describes a stable value-navigation or fluent API and explains why it does not expose a changing implementation detail. The number of dots is a prompt to inspect dependencies, not the rule itself.

M7 — Inheritance, Subtyping, and Refactoring

After slide: Subtype Contract Check — model answer

Source: lectures/M7.qmd → “Subtype Contract Check”

Clients of ArrayList can use the full List contract, including indexed insertion, removal at an arbitrary position, and sorting. Those operations need not preserve a stack’s last-in, first-out behaviour. For example, a client typed as List<E> can insert at index zero or remove an item from the middle; a Stack that rejects or reinterprets those calls cannot safely stand in for every ArrayList.

Keep the stack’s storage private and expose only stack operations such as push, pop, and peek, delegating internally to a list or deque. Inheritance does reuse implementation, but the inherited public API is broader than the stack contract. Accept another example if it identifies a valid base operation that breaks the promised subtype behaviour.

After slide: Compare Both Designs — facilitation notes

Source: lectures/M7.qmd → “Template Method or Composition?” → “Compare Both Designs”

Design pressure Template Method Composition
Choose formatting at run time Awkward if each formatter is a subclass; the job’s type fixes the variation. Inject or select a Formatter when constructing or running the job.
Share validation across unrelated jobs Reuse may require an artificial shared superclass. Reuse one Validator collaborator directly.
Guarantee publishing happens last A final run() can own the sequence and call publish() last. A run() method on the job can own the same fixed sequence and call publish() last.
Share state among steps The base class can hold shared state, but subclasses become coupled to its lifecycle and protected hooks. Pass a job context to collaborators or have the job coordinate explicit results.
Test failure in one step A test subclass can override a step, though it is coupled to the base class’s hooks. Inject a failing test double for that step and assert the job’s response.

For the stated combination of run-time formatter choice and validation shared across unrelated jobs, composition is a strong fit. Keep orchestration in ReportJob.run() so publishing remains last. Template Method remains reasonable when the algorithm and subclass family are stable and the sequence itself must be protected. The useful answer predicts which change will happen; “composition is always better” is not enough.

After slide: Exit Note (Inheritance and Subtypes) — model answer

Source: lectures/M7.qmd → “Inheritance and Subtypes” → “Exit Note”

The relation is syntactically valid but conceptually false because a Stack cannot preserve the List behaviour promised by ArrayList for operations such as indexed insertion and arbitrary removal. Accept another inherited operation that violates the subtype’s contract, with a client example.

After slide: Refactoring Studio — sample answer

Source: lectures/M7.qmd → “Smells and Refactoring” → “Refactoring Studio”

Before editing, add characterization tests for representative standard, student, and staff orders. Assert observable totals after the existing discount and tax rules, including rounding, and capture receipt or logging effects if callers rely on them. Add boundary cases where current rules have them. These tests record existing behaviour; keep tests for alumni pricing and the second jurisdiction separate as new-feature tests.

One cautious sequence is:

  1. Run the current suite and the new characterization tests to establish the baseline.
  2. Extract the existing price calculation into a clearly named method without changing its branches; run the focused tests.
  3. Separate tax calculation from order-kind pricing once the second jurisdiction shows that tax varies independently; run the focused and regression tests.
  4. Add alumni pricing behind the smallest variation point the current code warrants. A PricingPolicy/strategy is useful if pricing rules will continue to grow or vary independently; a small conditional may remain clearer if this is the only isolated addition.
  5. Add the jurisdiction policy and feature tests, then run the full suite and compare observable results for the old order types.

Run tests before the first edit, after every structural step, and after each intentional behaviour change. Rename or introduce a parameter object only if names or growing parameter lists make the code harder to understand. Replacing the conditional with polymorphism is an option, not a required destination. Keep each refactoring behaviour-preserving so failures identify which step changed the result.

After slide: Exit Note (Smells and Refactoring) — model answer

Source: lectures/M7.qmd → “Smells and Refactoring” → “Exit Note”

The refactoring that extracts or replaces the order-kind pricing logic should wait until a test captures the current observable totals, including discounts, tax, rounding, and any relied-on receipt effects. Accept a different refactoring and concrete behaviour that its change might alter.

M8 — Inversion of Control and GUI Event Handling

After slide: Observer/MVC Studio — sample answer

Source: lectures/M8.qmd → “Inversion of Control, Observer, and MVC” → “Observer/MVC Studio”

Use a NumberModel that owns the number and a small observer interface implemented by DigitView and WordView. The input handler translates a text or slider event into a number and asks the model to change it. After accepting a changed value, the model notifies its registered observers; it depends on the observer interface, not concrete view classes. Views render the supplied or queried value and do not update one another.

For push, call numberChanged(newValue) after the model stores the value. This is direct and avoids an extra read when observers need only the number. For pull, call modelChanged() after storing it; each observer reads the model. Pull can suit observers that need a consistent snapshot of several model fields, but gives them a model reference and may expose more query operations. Show the model as owner of number state and the input handler as the initiator of user-requested changes.

Notify after a successful state change, not before it. If setting the current value is a no-op, or validation rejects the proposed value, do not send a change notification. Keep observer registration and removal explicit so views that are no longer active stop receiving callbacks.

After slide: Exit Note (Inversion of Control, Observer, and MVC) — model answer

Source: lectures/M8.qmd → “Inversion of Control, Observer, and MVC” → “Exit Note”

Notify observers when the model has accepted and committed a value different from its current value, but not when validation rejects it or the requested value leaves the model unchanged. If the application treats a repeated event as meaningful, students should state that requirement and explain the notification policy.

After slide: Component and Handler Studio — sample answer

Source: lectures/M8.qmd → “GUI and Event Handling” → “Component and Handler Studio”

About 8 minutes, in pairs: the graph first, then the handler.

The component graph can show a root layout containing a number field, a slider, and the digit and word displays. The framework owns the component tree and invokes registered handlers. Mark the framework callback arrows from the field and slider events to their handlers, and the model callback arrows to the views.

For the handler, take the field or the slider. It reads the event, converts the value to the model’s number type, and calls model.setNumber(value). It should not directly update both displays or keep a second copy of the number: after translation and any input-specific error handling, it delegates the state change, and model notifications keep the views synchronized. A separate controller is appropriate if event translation or coordination grows, but a one-line handler need not acquire another layer.

If you have time, or for discussion after “Event Handler Boundaries”: an event-to-handler responsibility map, which the slide no longer asks for.

Event Handler responsibility Delegated operation
Submit button Read the field, parse and validate presentation input, show a local error if parsing fails model.setNumber(value) or a controller operation that validates the domain value
Slider change Convert the slider value to the model’s number type model.setNumber(value)
Model notification Update the digit and word displays View rendering methods

After slide: Exit Note (GUI and Event Handling) — model answer

Source: lectures/M8.qmd → “GUI and Event Handling” → “Exit Note”

This event handler should delegate the shared number change and its domain validation to the model or controller because other inputs must follow the same rules and the handler should remain focused on translating a GUI event. Accept presentation-specific parsing and feedback in the handler when the UI owns those concerns.

After slide: Demo: Callbacks in JShell — facilitation notes

Source: lectures/M8.qmd → “GUI and Event Handling” → “Demo: Callbacks in JShell”

About 10 minutes. Code is sample_code/event-handling-tutorial/jshell/Lucky.jsh. Either type the snippets into jshell, or run jshell Lucky.jsh for the whole thing. JShell does not need a main method or a class wrapper, so students see the pattern without ceremony.

1. The model and the observer interface

interface Observer { void newNumber(int n); }

class Model {
    private int number = 5;
    private final java.util.List<Observer> observers = new java.util.ArrayList<>();
    void addObserver(Observer o) { observers.add(o); }
    void removeObserver(Observer o) { observers.remove(o); }
    int getNumber() { return number; }
    void setNumber(int n) {
        if (n < 0 || n > 10) throw new IllegalArgumentException("0 to 10 only: " + n);
        number = n;
        for (Observer o : java.util.List.copyOf(observers)) o.newNumber(n);
    }
}

JShell prints “created interface Observer” and “created class Model”. Say: Model depends on the Observer interface and on nothing else.

2. Lambdas are observers

Model model = new Model();
String[] words = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
model.addObserver(n -> System.out.println("digits: " + n));
model.addObserver(n -> System.out.println("words : " + words[n]));
model.setNumber(7);
model.addObserver(n -> System.out.println("bar   : " + "#".repeat(n)));
model.setNumber(3);
model.setNumber(12)    // throws; nobody is told; model.getNumber() is still 3

Say: Observer has one method, so a lambda is a valid observer. This is the function-object idea from Chapter 3, and where Module 9 goes next. Show the exception: the number is rejected, nobody is told, and the state is unchanged.

3. Pull, with a read-only interface

interface ModelData { int getNumber(); }
interface PullObserver { void changed(ModelData data); }
class PullModel implements ModelData {
    private int number = 5;
    private final java.util.List<PullObserver> observers = new java.util.ArrayList<>();
    void addObserver(PullObserver o) { observers.add(o); }
    public int getNumber() { return number; }
    void setNumber(int n) { number = n; for (PullObserver o : observers) o.changed(this); }
}
PullModel pull = new PullModel();
pull.addObserver(d -> System.out.println("pull: asked, got " + d.getNumber()));
pull.setNumber(8);
pull.addObserver(d -> d.setNumber(0))     // does not compile

Say: the observer receives ModelData, so it can read but not change the model. JShell shows the compile error in place, which is the point of the Interface Segregation Principle.

4. The JDK’s own observer: PropertyChangeSupport

var pcs = new java.beans.PropertyChangeSupport(new Object());
pcs.addPropertyChangeListener("number", e -> System.out.println("changed " + e.getOldValue() + " -> " + e.getNewValue()));
pcs.firePropertyChange("number", 5, 7);
pcs.firePropertyChange("number", 7, 7)    // prints nothing
pcs.firePropertyChange("number", 7, 9);

Say: the JDK has had this since Java 1.1, and Swing uses it. It only notifies when the old and new values differ. That is the same guard the JavaFX slider needs (see the next slide).

5. JShell tips for the demo: /list shows what you typed, /vars shows variables, /reset clears everything, and redefining Model replaces it (JShell prints “replaced class Model” and resets variables of that type, such as model, to null, so create them again). If a snippet misbehaves, /reset and run jshell Lucky.jsh.

Design question: clamp or reject? The book’s LuckyNumber model accepts 1 to 10 and clamps: a value of 0 or less becomes 1 and a value above 10 becomes 10 (book pp. 195, 207), and its text handler ignores a non-number and uses 1 (p. 225). The model in this demo accepts 0 to 10 and throws IllegalArgumentException for anything else. Ask which is the better design decision. Clamping hides bad input from the caller, and the user never learns that 12 was out of range. Rejecting forces the controller to handle the error and give feedback, which is the “keep handlers thin but not careless” point from the slides. Neither is wrong; the point is that it is a decision.

After slide: Run Lucky Number — facilitation notes

Source: lectures/M8.qmd → “GUI and Event Handling” → “Run Lucky Number”

About 5 minutes. From sample_code/lucky-number-javafx, run ./gradlew run. The README lists five things to try. For the room, do these:

  • Move the slider and type a number: all three views follow. Ask who called IntegerPanel.newNumber (put a breakpoint there, or read the stack trace). The model called the view; the view never asked.
  • Open LuckyNumber.start and find the component graph. Open the lambdas in IntegerPanel and SliderPanel and find the handlers. Find Model.setNumber and find the domain change.
  • Remove the if (number != aModel.getNumber()) check in SliderPanel, run it, and move the slider. Ask what happens and why the check stops it. It is the same guard as in the JShell demo (PropertyChangeSupport does not fire when the value is unchanged).

M9 — Functional Design

After slide: Demo: Function Types in JShell — facilitation notes

Source: lectures/M9.qmd → “Functional Interfaces as Design Tools” → “Demo: Function Types in JShell”

About 8 minutes, placed after “Three Library Function Types” and “Reading Function Types” and before the Transform exercise. Type the lines into jshell, or paste them in groups. JShell already imports java.util.* and java.util.function.*. A runnable copy, FunctionTypes.jsh, is on disk (not in git) in sample_code/functional-types-tutorial/. The outputs below are from a real run; the $ numbers will differ when typed live. Say each Scala type aloud: it is the point of the demo.

1. A function is a value with a type (Scala: val twice: Int => Int)

Function<Integer,Integer> twice = x -> x * 2;
twice.apply(21)                      // 42

Say: Function<Integer,Integer> is the type, and apply is the one method. A lambda is a way to write a value of that type. Can show the simple function void twicef(Integer) as example. Scala

2. A predicate (Scala: val isEmpty: String => Boolean)

Predicate<String> isEmpty = s -> s.isEmpty();
isEmpty.test("")                     // true
isEmpty.test("abc")                  // false

3. A comparator (Scala: val byLength: (String, String) => Int)

Comparator<String> byLength = (a, b) -> Integer.compare(a.length(), b.length());
byLength.compare("ab", "c")          // 1
List<String> words = new ArrayList<>(List.of("pear", "fig", "banana"));
words.sort(byLength);
words                                // [fig, pear, banana]

Say: two arguments, so two arrows. The result is not a boolean, so Comparator is not a Predicate.

4. A method reference (Scala: val len: String => Int)

Function<String,Integer> len = String::length;
len.apply("hello")                   // 5

5. Composition (Scala: f.andThen(g) has type A => C, for f: A => B and g: B => C)

Function<Integer,Integer> inc = x -> x + 1;
twice.andThen(inc).apply(5)          // 11   Scala: twice andThen inc
twice.compose(inc).apply(5)          // 12   Scala: twice compose inc

Say: andThen runs twice first, then inc; compose runs inc first. Both names exist on Java’s Function and on Scala’s function types, so the code reads the same in either language.

6. A function that returns a function (Scala: val add: Int => Int => Int, which is Int => (Int => Int))

Function<Integer, Function<Integer,Integer>> add = a -> b -> a + b;
add.apply(2).apply(3)                // 5
Function<Integer,Integer> add2 = add.apply(2);
add2.apply(40)                       // 42

Say: add.apply(2) is itself a function. Supplying fewer arguments than the arrows allow gives a function back; this is partial application, and it is why Scala writes A => B => C with no parentheses.

7. A function that takes a function (Scala: def map[A, B](f: A => B, xs: List[A]): List[B])

<A, B> List<B> mapAll(Function<A,B> f, List<A> xs) { return xs.stream().map(f).toList(); }
mapAll(len, words)                   // [3, 4, 6]

Say: the type tells you almost everything the function can do. Give a list of A and a way to turn an A into a B, and the only sensible result is a list of B. That is why the Scala type is worth reading even when you write Java.

If it goes wrong: type the lines one at a time rather than pasting. /list shows what you have defined; /reset starts over.

After slide: Transform the Design — sample answer

Source: lectures/M9.qmd → “Functional Interfaces as Design Tools” → “Transform the Design”

Use the library types where their contracts say exactly what the client needs:

Comparator<Car> byAcceleration =
    Comparator.comparingDouble(Car::acceleration);

Predicate<Car> hasRequiredRange =
    car -> car.electricRange() >= minimumRange;

Function<Car, String> displayLabel =
    car -> car.make() + " " + car.model();

The comparator can be a named field or method if reused; inline it at a single call site if that is clearer. The range predicate captures a configuration value, so a named factory or policy can make sense if it is reused or represents a domain rule such as route eligibility. Use a method reference for label formatting only if an existing method has the right meaning and signature; otherwise a short lambda is readable. An application-defined functional interface is justified when a domain name or narrower contract adds meaning beyond Predicate<Car> or Function<Car, String>.

After slide: Exit Note (Functional Interfaces as Design Tools) — model answer

Source: lectures/M9.qmd → “Functional Interfaces as Design Tools” → “Exit Note”

A named class communicates intent better than a lambda when the behaviour has configuration or state, is reused, has a domain-specific name, or involves enough steps that its own type makes the code easier to inspect and test. A brief local transformation usually stays clearer as a lambda or method reference.

After slide: Pipeline Studio — sample answer

Source: lectures/M9.qmd → “Streams and Declarative Design” → “Pipeline Studio”

Assuming Card exposes isBlack(), isFaceCard(), rank(), and suit(), and Rank natural order is the desired rank order, one functional version is:

Map<Suit, List<String>> labelsBySuit = cards.stream() // Stream<Card>
    .filter(card -> card.isBlack() && card.isFaceCard()) // Stream<Card>
    .sorted(Comparator.comparing(Card::rank)) // Stream<Card>, rank order
    .collect(Collectors.groupingBy(
        Card::suit,
        LinkedHashMap::new,
        Collectors.mapping(card -> card.rank().name(), Collectors.toList())
    )); // Map<Suit, List<String>>

The ordered stream gives each suit’s collected list rank order; LinkedHashMap retains the order in which suits first appear. If the domain’s rank order differs from enum order, supply an explicit rank comparator. To count instead of retain labels, use Collectors.groupingBy(Card::suit, Collectors.counting()) after the same filter; add sorting first only if ordered traversal is part of the requirement.

An imperative version makes the mechanics explicit:

Map<Suit, List<Card>> selectedBySuit = new LinkedHashMap<>();
for (Card card : cards) {
    if (card.isBlack() && card.isFaceCard()) {
        selectedBySuit.computeIfAbsent(card.suit(), key -> new ArrayList<>())
            .add(card);
    }
}
for (List<Card> selected : selectedBySuit.values()) {
    selected.sort(Comparator.comparing(Card::rank));
}

Map<Suit, List<String>> labelsBySuit = new LinkedHashMap<>();
selectedBySuit.forEach((suit, selected) ->
    labelsBySuit.put(suit, selected.stream()
        .map(card -> card.rank().name())
        .toList()));

The stream stages are Stream<Card> through filtering and sorting, then grouping into Map<Suit, List<String>>; the mapping collector converts each grouped Card to String. Prefer the stream when these transformations read clearly together. The loop is reasonable if students need explicit intermediate state, custom early exit, or more involved grouping logic. Avoid side effects in map and do not chain stages just to make the solution look functional.

After slide: Exit Note (Streams and Declarative Design) — model answer

Source: lectures/M9.qmd → “Streams and Declarative Design” → “Exit Note”

A stream improves intent when the work is a short sequence of filtering, mapping, sorting, or grouping steps that reads as one transformation; an ordinary loop is clearer when the computation has early exits, complex state changes, or side effects that would be hidden in a pipeline. Accept a concrete example and explanation of what the reader must understand.

After slide: Quick Check: Stream It — facilitation notes

Source: lectures/M9.qmd → “Streams and Declarative Design” → “Quick Check: Stream It”

Key:

List<String> labels = fleet.stream()                         // Stream<Car>
    .sorted(Comparator.comparingInt(Car::electricRange).reversed()) // Stream<Car>
    .map(car -> car.make() + " " + car.model())              // Stream<String>
    .collect(Collectors.toList());                           // List<String>; or .toList()

Checked in JShell with a four-car fake fleet: the loop and the pipeline (both collect(Collectors.toList()) and .toList()) gave the same list, [Hyundai Ioniq 5, Tesla Model 3, Chevrolet Bolt, Nissan Leaf].

Order matters: sorted must come before map. The sort key, electricRange, belongs to Car; after map the elements are only Strings, so a student who maps first cannot sort by range.

Follow-up questions:

  • What type does each stage produce? (Stream<Car>, Stream<Car>, Stream<String>, List<String>.)
  • Would a plain loop be clearer here? A sensible answer: for one pass with two simple steps the pipeline reads well; with early exit or side effects a loop is clearer.
  • Collectors.toList() returns a list the contract does not promise is mutable; Stream.toList() returns an unmodifiable one.

Mentimeter sequence (outline in 365-admin/menti-streams-quickcheck.md; no deck has been created yet): (1) Multiple Choice, stage order: sorted, map, collect is correct; (2) Open Ended, “Type your pipeline”: read two answers aloud; (3) Multiple Choice, result type: List<String> is correct.

In the open answers, look for: map before sorted (cannot sort by range); a missing collect or toList; sorting ascending without reversed(); a forEach that adds to an outside list (side effect in a pipeline). Answers are anonymous and shown on screen, so read out only the instructive ones.

M10 — Synthesis and Design Judgement

The notes follow lectures/M10.qmd in two parts, the recorded video (“Agents in the Design Lifecycle”) and the live class (“Review and Wrap-Up”), then lectures/final-review.qmd (the course review). Slides that need nothing are left out.

After slide: What Changes When an Agent Implements? — facilitation notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “What Changes When an Agent Implements?”

Students pause the video and write an answer. The next two slides (“What Agents Take On”, “What Stays With You”) give the course’s answer, so students can compare it with what they wrote. Good answers usually name evaluating, deciding or specifying; weaker ones say “nothing” or “prompting”.

After slide: What Agents Take On, What Stays With You — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “What Agents Take On” and “What Stays With You”

Keep to what the course has students do with agents in A3 to A6. The AI lecture (ai-and-design.qmd) adds that current agents work best at the function or class level, so scope your changes. That is the instructor’s guidance in that lecture, not a measured result; do not present it as a finding.

After slide: You Cannot Supervise What You Cannot Evaluate — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “You Cannot Supervise What You Cannot Evaluate”

This is the course’s core claim (365-admin/philosophy.md): using an agent well is a matter of recognising whether its output is good, and that skill is built by doing the work yourself first. The six questions are the checklist students are expected to apply to generated work in A3 to A6.

After slide: Cognitive Debt — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “Cognitive Debt”

“Cognitive debt” is this course’s own term for the gap between a system that runs and a team that understands it (365-admin/philosophy.md). The repository does not cite a study for it, so present it as the course’s framing. The Tao talk linked on the slide is cited in TAO-AI.qmd and is about cognitive skill loss.

After slide: Three Kinds of Concept — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “Three Kinds of Concept”

The sorting comes from the course design notes (365-admin/365_AI_plan.md: teach deeply, teach as tradeoffs, recognize). Students have not seen it; present it as a way to supervise an agent, not as course history.

After slide: Judge Output By These — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “Judge Output By These: Weigh the Tradeoff” and “Judge Output By These: Recognize”

Each question on the tradeoff slide comes from a cost a module taught:

  • Strategy (M3, M9): a small stateless Strategy can collapse into a function value (M9, “Strategy and Command Revisited”).
  • Singleton (M4): global access hides a dependency, and tests share state.
  • Decorator (M6): the wrappers keep the component type, but the original object’s identity is no longer the client’s main abstraction.
  • Command (M6): a named command must earn its cost over storing a lambda.
  • Observer (M8): pull gives every observer access to the model.
  • Composite (M6): the question is the standard smell, not a quote from the slides.

The course design notes also list Factory and Facade as tradeoff-level patterns, but the slides barely cover Factory (it appears in passing in M3 and M6) and do not cover Facade, so they are left off.

On the recognize slide, only Prototype (M6) and Flyweight (M4) are taught. The slide says Memento, Bridge and the others are not covered. The course design notes also list Visitor, Interpreter and Abstract Factory at this level; Visitor was removed from M8.

After slide: The Project Path — notes

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “The Project Path”

The AI levels come from the sequence table in project/project_exercises.md (A1 A, A2 A, A3 D, A4 C, A5 D, A6 E). The A4/5 section of the same file says Level C for both; the slide follows the table. The two should be reconciled in project_exercises.md.

After slide: Homework: Spot the Force (continued) — model answer

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “Homework: Spot the Force (continued)”

Both snippets are the M4 slide “Convenient Global Access”.

  1. The test can pass alone and fail after another test because GameModel.instance() is shared mutable state, so tests depend on each other’s order.
  2. The design force is a hidden global dependency with shared mutable state.
  3. It is a Singleton, so it is a weigh as a tradeoff concept; it also breaks state, testability and dependency injection, which are know deeply concepts.

Revision: inject a GameModel into the clients, option 2 of the M4 slide “Compare Three Designs”. Whether the homework is collected is not decided; the slides give no submission instructions.

After slide: Homework: Which Row Is Weakest? — sample answer

Source: lectures/M10.qmd → “Agents in the Design Lifecycle” → “Homework: Which Row Is Weakest?”

There is no single answer. A good answer picks a row of the project map, names a specific artifact from the team’s own repository, and gives a check that could be run on it (for example, for A6: run the smoke test against the deployed URL and see what it does not cover), and names the textbook module that says what to look for.

After slide: Entry Decision (Review and Wrap-Up) — notes

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Entry Decision”

Good answers name a specific choice an AI tool made in the student’s project (a library, a structure, a pattern) and give evidence for or against it, such as a test, a change request, or a line of the AI log. It leads into the cross-language part: the agent picks a mechanism, and the student judges whether it resolves the design force. Students return to their examples in the Reflection Matrix, so do not collect answers in full.

After slide: The Agent Picks the Idiom — notes

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Same Force, Different Mechanism” and “The Agent Picks the Idiom”

The table “Where Is the Contract? Naming and Checking” in cross-language-m2-6.qmd is the source: Java uses an interface, checked by the compiler; Python uses a Protocol or abc.ABC, checked by a type checker (and, for ABC, at instantiation); JavaScript uses a convention that nobody checks. The slide leaves out ABC to keep one idea. C is left out because the class skips it.

After slide: Today’s Path — facilitation notes

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Today’s Path”

The slides to run, in this order, by title:

  1. cross-language.qmd: “Language Philosophy” and “Four Bets: What They Cost and Buy”.
  2. cross-language-m2-6.qmd: “The Running Example: Shuffler”, then “Shuffler in Java”, “in Python” and “in JavaScript”.
  3. cross-language-m2-6.qmd: “Decorator: The Idea”, then “Decorator: Java”, “Python” and “JavaScript”.
  4. cross-language-m2-6.qmd: “JavaScript: Classes Sit on Prototypes”.
  5. The exercise, next: “Breaking the Contract: Java”, “Python” and “JavaScript” in cross-language-m2-6.qmd.

Skip the C slides. Optional extras: “Template Method: The Idea” and the slides after it in cross-language-m2-6.qmd, and the section “M9 — Strategy and Decorator as Functions” at the end of cross-language.qmd.

cross-language-m2-6.qmd is draft: true (“Extras”), so it is not published. Present it from the preview. Only cross-language.qmd is linked for students.

After slide: Functional Style slides — notes

Source: lectures/cross-language.qmd → “M9 — Strategy and Decorator as Functions”

The five slides are “Functional Style: A Shuffler Is a Function”, “Implementations Are Values”, “Inject the Function”, “Decorator Wraps a Function” and “When a Class Still Earns Its Place”. The Scala was run with scala-cli 1.19.0 (Scala 3.10.1): Deck(cards, inOrder).shuffled == cards is true, and withLogging(random) prints the log line and returns the shuffled list.

M9 uses Scala only to read function types; these slides use a little more (a val, a def and a small class). The Scala shufflers return a new list, whereas the Java shuffle changes its list in place; the slide says so. The reasons on the last slide for a class still winning come from M9, “Strategy and Command Revisited”.

After slide: Judge the Idiom — model answer

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Judge the Idiom” and “The Language Does Not Judge for You”

  1. None of the three rejects it. Inserting at the front is still a public operation of ArrayList, list or Array, so all three accept it.
  2. The design force broken is the stack’s discipline: a Stack that is a List must accept everything a List accepts, and a client can bypass the stack operations. This is inheritance used only to reuse code (M7) where composition fits (M6).
  3. Hold the list as a field and forward only the stack operations, as in “Avoiding It in C”, where C has no inheritance to misuse.

The next slide’s point is that a compiler checks the mechanism, not the force. The published slide “A Subtype Must Honour the Base Contract” in cross-language.qmd makes the same point.

After slide: Reflection Matrix — notes

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Reflection Matrix”

Listen for a specific artifact in every row, a difference between where AI accelerated the work and where it created cognitive debt, and a named judgment that improved the output. “It was faster” with no artifact is a Developing answer.

After slide: Exit Note (Review and Wrap-Up) — model answer

Source: lectures/M10.qmd → “Review and Wrap-Up” → “Exit Note”

Answers depend on the student’s artifacts. A strong response names a usable skill—such as tracing a dependency to a test seam, checking a generated change against a requirement, or describing a design tradeoff—and gives a project example where they can apply it without AI. Look for a skill that describes an action the student can perform and evaluate, rather than only a pattern name.

After slide: Exit Note (Final Review) — model answer

Source: lectures/final-review.qmd → “Class 35 — Final Review” → “Exit Note”

Answers should identify a specific unresolved project risk and a next piece of evidence that could reduce uncertainty. For example: “The service may not recover cleanly after a database outage; I would inject a connection failure in a staging integration test and observe recovery, health reporting, and alerting.” Accept other risks when the proposed evidence tests the stated concern rather than merely adding more code or coverage.

After slide: Compare Three Plausible Designs — answer example

Source: lectures/final-review.qmd → “Class 35 — Final Review” → after “Compare Three Plausible Designs”

Claim: The design hides a global dependency.

Evidence: Clients call Service.instance() and tests share its mutable state.

Consequence: Tests become order-dependent and a second service instance is expensive.

Revision: Inject a service instance through the client constructor.

Tradeoff: Object construction becomes more explicit and requires composition at the application boundary.

Specific evidence distinguishes analysis from vocabulary recall.

After slide: Apply the Lenses — notes

Source: lectures/final-review.qmd → “Class 35 — Final Review” → “Apply the Lenses”

Students place real project decisions in a context (obvious, complicated, complex, or Explore, Expand, Extract) and say what amount of design fits: a quick spike, a refactoring, an ADR, or an architectural decision. Look for a reason tied to the uncertainty, not for a single right quadrant.

Archived Notes for Disabled Slides

Would follow: M3 Compare Alternatives (currently commented out)

Source: lectures/M3.qmd → commented-out “Compare Alternatives”

  • The concrete Deck and string-based ordering disappear from HandBuilder.
  • The composition root—the caller or factory that creates HandBuilder—chooses the implementations.
  • A stateless CardOrder can be a lambda, and Comparator<Card> may remove the custom type entirely.
  • CardSource is cohesive if every client operation concerns supplying the next card; split it if clients are forced to depend on unrelated deck operations.
  • Flexibility costs extra types, construction wiring, indirection, and more concepts for a reader to track.
  • The stated need for standard decks, multiple decks, fixed sequences, and different hand orders is evidence of real variation. Without those cases, the interfaces would be speculative.

Would follow: Ethics — What Is Within Your Freedom? (currently commented out)

Source: lectures/ethics.qmd → commented-out “What Is Within Your Freedom?”

This is a deliberately compact riff on 15% Solutions. Keep the essential constraint: the action must already be within the student’s freedom and resources.

Would follow: M8 Visitor Exit Note (removed from the deck)

Source: lectures/M8.qmd (Visitor section removed; see git history) → “Visitor as a Recognition Pattern” → “Exit Note”

Visitor is overkill here if the node types are stable and only one or two straightforward operations need recursive traversal; direct methods, a small external traversal, or a stream can be clearer than accept methods and double dispatch. It is also a poor fit when node types change frequently or a search needs simple early termination. Accept another answer that names the expected change and the ceremony Visitor adds.