Lecture 12 — Debugging Lab: Real Defects

Position in the course

This is lecture 12 of 32. It belongs to the course arc described in the course outline and uses the standard interactive case method: display, attempt (5 minutes), discuss, reveal, name the technique.

This lecture runs as a clinic session (protocol-driven defect hunting; see the timing plan), not the standard four-case rhythm.

Learning objectives

By the end of this lecture students can do all three under time pressure, which is what the four cases exercise.

Prerequisite knowledge

Before this lecture: Lectures 07–08 — Debugging method and testing

Assumed fluencies:

Preparation task: Skim cs-045–cs-048 student pages; do not read solutions.

Detailed topic outline

Core (mandatory):

  1. a repeatable defect-hunt protocol
  2. statistics defects that look correct
  3. sentinel and default traps
  4. tuple swap and reference traps

Extension (optional enrichment):

  1. bisecting a regression
  2. regression suites as memory

Case sequence

CaseTitleDifficulty
cs-045The Median That LiesBeginner
cs-046The Phantom ZeroFoundational
cs-129The Missing MarksFoundational
cs-047The Swap That Wasn'tIntermediate
cs-130The Duplicate RowsIntermediate
cs-048The Regression ZooAdvanced

Display each case full-screen from the student page (cases cs-045–cs-048); instructor pages cs-045–cs-048 under case-studies/instructor/ hold the full solutions, reveal guides, and discussion prompts. Applied additions cs-129, cs-130 extend the session as optional extra attempts or homework; they share the lecture's theme but teach an applied, real-world angle.

Timing plan (120 minutes)

Format: clinic session — deliberately not the standard case rhythm.

MinutesSegment
0–10Recall: the protocol from earlier lectures, on one slide
10–20Protocol refresh: reproduce, hypothesise, cheapest experiment, isolate, fix, re-test
20–45Case 1 (cs-045): full clinic cycle with written hypothesis ladders
45–50Break
50–80Cases 2–3 (cs-046, cs-047): two attempts, one discussion, two reveals
80–100Case 4 (cs-048): solo attempt under time pressure; reveal as a walkthrough
100–110Deliberate-practice hunt: apply the protocol to a fresh defect
110–120Protocol reflection, exit questions, homework

Timing flexes with the room: if a case ignites the class, let the discussion run and compress the synthesis; if the attempts stall, harvest partial attempts rather than extending the clock.

Worked examples

Instructor demonstration to open the lecture: Trace the median defect (cs-045) on three inputs where it answers correctly, then the fourth where it lies — the class predicts which.

Classroom activities

#ActivityMinutesFormat and prompt
1Bug triage board8Four defect reports are triaged on a public board: reproduce, hypothesise, isolate — in that order.
2Bisect demonstration7The regression zoo (cs-048) is halved twice on the board before any code is read.
3Fix-the-zoo hunt15Teams get one defect each with a test suite; fix without breaking a single green test.

Board plan

Instructor explanation notes

Reading the room. The second clinic. The protocol from lecture 7 is now executed under time pressure, with regression thinking added: fix nothing without a test that fails first.

Running the reveal. Choose the weakest-weak-spots live by poll; the clinic time is theirs, not the syllabus's.

Lecture focus. One sentence to repeat verbatim: Reproduce, hypothesise, isolate, fix, re-test — in order.

Common misconceptions

Each case's instructor page lists the specific wrong turn to expect; the reveal should address it by name.

Student practice exercises

Core:

  1. Reproduce, isolate, and fix the phantom zero (cs-046) using the clinic protocol; log every experiment.
  2. Write the regression suite for the swap-that-wasn't (cs-047) before fixing it.
  3. Bisect a provided five-commit regression story; name the culprit commit.

Enrichment (optional):

Formative assessment

Exit questions (choose one; answer on a card in 60 seconds):

  1. Why must the reproduction step precede any hypothesis? Expected: an unreproduced defect cannot be falsified; you would be guessing
  1. What does 'fix without breaking green tests' require? Expected: a regression suite run before and after every change
  1. Name the isolation technique used on cs-048. Expected: history bisect: halve the commit range each experiment

Cards are skimmed before the next lecture; three answers become the framing. Persistent wrong answers route students to the review stations of lecture 16 or to office hours.

Homework and preparation

Learning-outcome mapping

Differentiation