2.2.3 · D3Design Principles

Worked examples — YAGNI — You Aren't Gonna Need It

2,392 words11 min readBack to topic

Recall the single tool we use. When you consider writing a piece of speculative code, four plain-English quantities exist:

Why an inequality and not a yes/no rule? Because "should I build this?" is really "is the expected gain bigger than the certain loss?" — a comparison of two numbers. An inequality is exactly the tool that answers "which side is bigger?". See the balance-scale picture:

Figure — YAGNI — You Aren't Gonna Need It

The scenario matrix

Every real coding decision falls into one of these cells. Our job below: hit every cell with a worked example.

Cell Regime of the inequality Real-world flavour
A tiny, → LHS RHS classic speculative "config layer"
B high, but small (cheap to add later) → still fails "obvious" future feature that's cheap to add later
C now (present requirement) → not speculative at all validation / auth / security
D genuinely high and huge & irreversible later → LHS wins the rare build-now exception
E Degenerate: (truly free hook) the "it's basically free" claim
F Limiting case: as you wait (deferral raises certainty) forecast-then-verify timing
G DRY-vs-YAGNI collision (duplication count ) abstract now or wait for third?
H Exam twist: numbers given, decide + justify plug-in computation

Worked examples

The figure below turns this example into a picture: the orange bar is the claimed 5-minute cost, the tall violet bar is the ignored lifetime , and the magenta dashed line is the expected benefit h. Notice how the benefit line clears the "free" bar on the left but is buried under the real cost on the right — that visual gap is why the hook isn't free.

Figure — YAGNI — You Aren't Gonna Need It

Active recall

Recall Cover the answers

Which cell is a present requirement (validation/auth)? ::: Cell C — now, YAGNI is silent, build it well. In Example 5 what was the lie? ::: That ; real lifetime carry (~2 h) flips the decision to "don't build." Break-even probability formula? ::: . Difference between and ? ::: = savings you collect for guessing right today; = the bill you actually pay if you build it later. Why does a high still not justify Example 2? ::: Because (savings) is tiny — building later is cheap, so LHS stays below RHS. When does YAGNI itself say "build now" (Cell D)? ::: When is high AND is huge/irreversible, so beats the certain cost.

Connections