W WolfCode · CSC 141

Walkthrough: Distance (Incremental Build)

例题: 距离 (增量构建)

≈ 10 min · python-decomposition python-functions · Open in WolfCode

Build distance() in four steps. Each step runs. Each step verifies one new thing. The textbook's most-quoted example of incremental development.

Python · runnable

The four-step build

  1. Skeleton: return 0.0 — verify it runs
  2. Compute dx, dy: print them — verify diff calculation
  3. Sum of squares: print dsquared — verify it equals 25
  4. sqrt + remove scaffolding: final form