Video in progress
When is it worth writing a short design doc before starting a feature, and what should it contain?
I write one if the work is longer than a few days, touches another team, or changes a DB schema or an API contract. One or two pages: the problem, the chosen solution, the options considered, risks and open questions.
📖 Answer
A design doc for a two-day bug fix is bureaucracy. But starting two weeks of work without agreeing with anyone, and getting a review comment of "this approach is completely wrong", is even more expensive.
The cases where I write one:
- a new table, or a serious change to an existing schema;
- an API used externally or by another team;
- there are several options and the choice isn't clear (for example, a synchronous call or an event);
- there's a performance or security requirement.
The template is short:
## Problem
There's no partial refund, and support calculates it by hand (~40 a day).
## Solution
A refund_items table, POST /orders/{id}/refunds, amounts in BigDecimal.
## Options considered
- A JSON column on the refunds table: hard for reports, rejected.
## Risks and open questions
- Does Payme support partial refunds? (spike, 1 day)
- Do the old full refunds need migrating?
The most useful parts are "options considered" and "open questions". They show the reviewer exactly where to think.
I write the doc, send it to two or three people and give them a day for comments. After that the coding usually goes faster, and in PR review there's no architecture argument, because it already happened.
Sign up to mark studied questions and save your progress.