engineering · process
Why I keep a failure case first
When a requirement arrives, the tempting first move is to write the happy path. It feels like progress: fields appear, the screen fills, the demo works. Then the first month-end close arrives and the numbers do not reconcile.
So I start somewhere else.
Write the failure down
Before code, I write one paragraph: what must never happen. For a settlement system it was “the sum of line items must equal the invoice total, always, including after a partial refund”. That single sentence decided more of the schema than any meeting did.
Make the invariant checkable
An invariant nobody can check is a wish. So each one gets a query, a test, or a job that screams when it breaks. The point is not coverage. The point is that the system tells you it is wrong instead of a customer telling you.
Keep the diff small
Small diffs are how a team survives a migration. If a change touches the billing path, the auth path and the reporting path at once, nobody can review it honestly. I split it until each piece has one reason to exist.
None of this is clever. It is just the order of operations: failure first, invariant second, code third.