Walkthrough: Distance (Incremental Build)
例题: 距离 (增量构建)
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
- Skeleton:
return 0.0— verify it runs - Compute dx, dy: print them — verify diff calculation
- Sum of squares: print dsquared — verify it equals 25
- sqrt + remove scaffolding: final form