Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Cascades are self-inflicted

โญโญโญ advancedโณ 10 min read๐Ÿ“ Lesson 222 of 256

Prefer self-contained implementations; guard boundaries between parts as if they cannot see each other's bugs.

Cascading errors are self-inflicted. They happen when one part's code is reused wrongly by another โ€” part (c) calls your broken part (a) and inherits the failure. The isolation techniques:

  • Prefer self-contained implementations. When a part can be written with its own loop in six lines, do that instead of composing a ten-line dependency chain โ€” cross-part reuse saves writing time but spreads damage.
  • If the spec REQUIRES calling an earlier method (some FRQs say "you may call methodFromPartA"), call it as specified โ€” but test it with a mentally-hand-computed example, since the rubric gives the earlier method's correct behavior on demand.
  • Compartment failures: a null-check missing in part (a) should not reach part (c). Guard boundaries between parts as if they were teams that cannot see each other's bugs.

The graded exercises here make the isolation concrete: each part is tested independently, so a bug in one cannot poison another's score.