Ch10 Discussion
Discussion Guide
Warm-up (think–pair–share, 5 min). "You have three kinds of solver that all 'advance a field one step' but do it differently. How would you organize the code without copy-pasting the shared parts?" Surfaces the motivation for inheritance/abstract interfaces before any syntax.
Main discussion (20 min).
1. Free or ruinous? Put a single design on the board — a class(solver_t) handle with a step method —
and ask: "Is the polymorphism cheap or expensive?" Force them to answer "it depends where step is
called." Then show the two call sites (once per timestep vs once per cell) and let them compute the cost
difference (Exercises 10.22–10.23). Lands the §10.5 rule as their conclusion.
2. select type on trial. Show the CS-02 select type dispatcher and the refactored abstract version.
Ask: "When a fourth scheme is added, which code must change in each design?" Reveal that "the driver never
changes" is the decisive property — and that a behavior-implementing select type is a method waiting to
be written.
3. When NOT to. "Name a part of your solver where adding OOP would be pure overhead." Ensures students
learn OOP is a specialist tool for managing variation, not a default — which keeps the pro-OOP case
credible (mirrors Ch. 1's honesty discipline).
Group activity (12 min). In pairs, extend the shape hierarchy with a triangle_t (Exercise 10.16) on
paper, then predict the printed total area. Collect: the diagnostic is whether they (a) used a keyword
in the constructor and (b) recognized the summing loop does not change. Then have them state, in one
sentence, where they would and would not put a class in the solver.
Exit ticket. "State the one performance rule of this chapter, and give one place dispatch belongs and one place it must never go." Anything naming coarse-grained (per-step / which-solver) vs fine-grained (per-cell) is a pass.