Ch13 Discussion

Discussion Guide

Warm-up (think–pair–share, 5 min). "Describe a time a program gave you a wrong answer rather than an error. How long did it take to notice, and why?" Surfaces the silent-failure problem the chapter attacks.

Main discussion (15–20 min). 1. Loud vs recoverable. Put three failures on the board — a missing config file, an out-of-memory allocation, a nx = 0 in a valid-looking file. For each, ask: recover (status return) or halt (error stop)? There is no single right answer; the reasoning is the point, and it previews Case Study 2's taxonomy. 2. Assertions vs error handling. "Should you assert that a file exists? Should you assert that n > 0 at a routine's entry?" Draw out the distinction: the world's behavior (handle) vs your own invariants (assert). 3. The cost of checking. "You have a stencil that runs for a week. Which checks stay on in production, which come off, and how do you decide?" Connects §13.5's removable checks to the performance theme and Ch. 30.

Group activity (10 min). In pairs, hand each pair the buggy accumulate subroutine (the §13.6 Find-the-Bug, implicit save). Without a computer, they must (a) predict its output over three calls, (b) name the bug, and (c) write the two-line fix and the explicit-save alternative. Collect predictions first — the surprise is the teaching moment.

Exit ticket. "In one sentence each: when do you use stat/iostat, and when do you use an assertion?" (Checks the §13.5 distinction — expected errors vs impossible conditions. Anything that separates 'the world's faults' from 'my logic's faults' is a pass.)