In everyday life
Like a diesel pump nozzle that is too wide for a petrol car’s tank. The wrong match is stopped by its shape, before anyone has to remember which pump is which.
One case
A bank app refunds wrong fees with move(from, to, amount): from the bank’s fee account to the customer’s account. Both ids are plain text. A developer swaps the two in one place, and every test still passes. Over 300 refunds, the bank takes the money from the customer instead of paying it back: a $50 refund costs the customer $50.
Every case
A test checks only the cases someone thought to write. A type checkerA program that reads the code, without running it, and reports any value used as the wrong kind. checks every line on every run, usually in seconds. Give each kind of value its own type, and whole classes of mistakes cannot be written: a customer’s account where the bank’s own account belongs, a payment that is both settled and cancelled, a status nobody handled. The editor marks the mistake while you type, which is the cheapest moment to find it. An agent gets the same red mark and can fix it before anyone reads the code.
The word
Engineers call this
Shape the types so the wrong code cannot be written. Turn a mistake you found once into an error the checker finds every time.