Chapter 11: Design

Naming

Choosing what to call things so a reader can guess what they do without opening them. unpaidInvoices tells you something. data tells you almost nothing.

An agent finds its way round a codebase largely by searching for words. If the thing it needs has a vague name, the search misses, and it may write a second copy of something that already exists. A name is also the cheapest context there is, since it arrives at every place the thing is used.

Say it to your agent

“In src/billing/reminders.ts, rename data to unpaidInvoices and process to sendPaymentReminder across every caller, using the language server's rename and not find and replace. Behaviour must not change. Run bun test afterwards.”

The workshop

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