Ch11 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). "In one sentence, what is the difference between p => a and p = a?" Collect a few; correct any that conflate them. This surfaces the single most important misconception before the lecture builds on it.

Main discussion (15–20 min). 1. The silent-failure problem. Put the dangling-pointer fragment on the board. Ask: "Why is a bug that associated() cannot detect worse than one that crashes immediately?" Draw out that undetectable bugs survive to production and erode trust in results — tie to the book's hand-computed-output honesty ethic. 2. Rewrite the instinct. "You need a collection whose size you learn at run time. A C programmer reaches for a linked list. What does a Fortran programmer reach for, and why?" Reach the growable allocatable array (Case Study 2) and the prefetch/vectorization argument. 3. When is a pointer actually right? Have the class enumerate the five legitimate uses and give a concrete example of each. Ensures students learn the rule is "prefer allocatable," not "never use pointers."

Group activity (10 min). In pairs, hand each pair the buggy inherited stack from Case Study 1. Task: find all three bugs and, for each, state the one-line fix. Then answer the harder question: "Should this be a pointer structure at all?" Have one or two pairs present; converge on the array port.

Exit ticket. "State the allocatable-vs-pointer rule, and name one situation that genuinely needs a pointer." (Checks the §11.4/§11.5 core; anything naming aliasing/links/polymorphism/callbacks/C-interop is a pass.)