2.2.3 · D1Design Principles

Foundations — YAGNI — You Aren't Gonna Need It

2,701 words12 min readBack to topic

The parent note leans on a little expected-value formula and a handful of words — probability, cost, carry, abstraction, speculation. This page builds every one of those from nothing, so line one requires no prior software or maths knowledge. If you can read a shopping receipt, you can read this.


Symbol 0 — What is a "feature"? (the thing we might not build)

Before any maths, we need the object the whole topic argues about.

Picture a program as a box. Each feature is a small extra gadget bolted onto the box. Some gadgets are used every day; some are bolted on "for later" and gather dust.

Figure — YAGNI — You Aren't Gonna Need It

Symbol 1 — "Speculative" vs "needed now"

The single most important distinction. Get this wrong and every later symbol misleads you.

The picture: a timeline. "Now" is a solid line; the future is fog.

Figure — YAGNI — You Aren't Gonna Need It
Needed-now lives in the solid part
do it, and do it well
Speculative lives in the fog
defer it until the fog clears

Symbol 2 — , a probability (a number between 0 and 1)

Now our first mathematical symbol. We use it because "the future is uncertain" is vague — we want a dial for how uncertain.

Why a number and not just words? Because we are about to compare the value of building-now against waiting, and you cannot compare "probably" against "expensive" — you can compare against a cost. The number lets us do arithmetic.

The picture: a slider from a definitely-not (left) to a definitely-yes (right). Speculative software features sit far to the left — requirements drift, so most guesses are wrong.

Figure — YAGNI — You Aren't Gonna Need It

Symbol 3 — Costs and a time horizon: , , ,

"Cost" here is not just money — it is total effort/time/risk, measured in the same units so we can add and compare them. Think of every cost as a pile of coins.

The picture: is a one-time payment; the carry is a stack of small daily bars, and its total area grows the longer the horizon.

Figure — YAGNI — You Aren't Gonna Need It

Symbol 4 — Two options compared, and time value of money

We now have a chance (), costs, and a horizon. But a decision is a comparison of two options, so we must write down both — not just building.

Why multiply? Imagine flipping a coin for $. Half the time you win $, half the time $. Over many flips your average win is 0.5 \times \10 = $5$. Multiplying probability by reward is exactly "average over all the times you play". That is the only tool that lets an uncertain future reward be weighed against a certain present cost.


Symbol 5 — "Abstraction" and the Rule of Three

The parent talks about not adding an abstraction too early, and hands timing off to the Rule of Three.

The picture: one dot is just a dot; two dots could be a hundred different lines; three dots pin down the pattern.

Figure — YAGNI — You Aren't Gonna Need It

How the foundations feed the topic (walk it top to bottom)

Read the map one link at a time — each node is a symbol you just learned, and each arrow is the sentence "…which lets us define…":

  1. FeatureSpeculative vs present: knowing what a buildable chunk is lets you split "asked for now" from "guessed for later".
  2. Speculative vs presentp and the costs: only the speculative side gets a probability and a carrying cost worth worrying about.
  3. Costs need a horizon H → they combine into total carry , and feed the savings S.
  4. p and Sexpected value (), the average benefit.
  5. Expected value, plus the waiting baseline , → the two-option inequality.
  6. The inequality, plus the Rule of Three timing, → the full YAGNI decision.

Feature: a buildable chunk

Speculative vs present

p: probability future arrives

H: time horizon in days

Costs: build, carry, later

S: savings if guess right

Expected value p times S

Waiting baseline p times C later

Two option inequality

Abstraction and Rule of Three

YAGNI decision


A tiny worked check (numbers make it concrete)


Equipment checklist

Recall Are you ready for the parent topic? (cover the answers)

What is a "feature" in one line? ::: A buildable/skippable chunk of program behaviour. Difference between speculative and present requirement? ::: Present = a real current demand asks for it; speculative = only a guess about the future asks for it. What does measure and what range does it live in? ::: The probability the guessed future actually arrives, a number from 0 to 1. What is and which two numbers make it? ::: The total cost of keeping code alive, equal to the per-day cost times the horizon: . Why does the horizon matter? ::: A daily cost is meaningless until you say how many days you carry the code; a long horizon makes carry ruinous. Why can be smaller than ? ::: Later you know the real requirement, so you build the right shape with no wrong-guess rework. What exactly is , and why is ? ::: The future spending you avoid by pre-building (later build plus dodged rework); it never exceeds because part of a guessed design is usually the wrong shape. What is the waiting baseline (why isn't it zero)? ::: If you wait, with chance you still build later, so , not . State the honest two-option build-now condition. ::: . How does discounting (time value of money) tilt the decision? ::: Future benefits and are worth less in today's terms, pushing the choice further toward "wait". When does the Rule of Three say to add an abstraction? ::: On the third real occurrence, not the first or second. Does YAGNI tell you to skip input validation on today's endpoint? ::: No — that's a present requirement, not speculation.


Connections

  • YAGNI — You Aren't Gonna Need It — the parent topic these foundations unlock.
  • Simplicity and KISS — Keep It Simple — build present things simply.
  • Rule of Three — the timing rule for abstraction, built above.
  • DRY — Don't Repeat Yourself — removes existing duplication; don't apply it speculatively.
  • Premature Optimization — same speculation disease, performance flavour.
  • Extreme Programming — where YAGNI comes from.
  • Technical Debt — speculative code is pre-paid debt with no asset.