Chapter 11: Design

Now the most repeated advice in programming, and among the most misapplied.

DRY

Also called Don't repeat yourself

Don't repeat yourself: each piece of knowledge should live in one place, so changing it means changing it once. It is about knowledge and not about text. Two lines can look alike and mean different things.

A session that doesn't know a helper exists may write it again. The classic result is a fix that lands in three of four copies, with the fourth going wrong months later. When a rule has one home, an agent can't miss a copy.

Say it to your agent

“The 20% tax rate is written in four files. Make one TAX_RATE in src/tax.ts and import it everywhere. Then grep for 0.2 and 1.2 and show me that those results have gone.”

The workshop

Name a word, or describe what you mean in everyday language.