The Error Case Is the Real Design

Anyone can write the happy path.
Input arrives, everything’s fine, output appears.

The real design is everywhere else.

The null. The timeout.
The input no sane person would send,
that someone sends anyway.

Early on I treated error handling
as something to bolt on at the end.

Then I learned the errors
were most of the actual work.

Now I write the unhappy path first,
while my head is clear,
before I’m tired and just want it to compile.

Code that only handles success
isn’t finished.
It’s just optimistic.

– Serguey Asael Shinder

Leave a comment