A Sonnet for Error Handling

Malina Tran
Tech and the City
Published in
1 min readAug 24, 2016

Please note: this poem is not a traditional Shakespeare sonnet, which is written in iambic pentameter, a rhyme scheme in which each sonnet line consists of ten syllables (five pairs of iamb — one unstressed syllable followed by one stressed syllable). I hope you enjoy it anyway!

Weekday, clock ticks, cursor blinks
A Java program is sitting, waiting in IntelliJ
Another day of unanswered emails and unopened links
We read about try-catch-finally (ah, to throw exceptions!) today.

The crafter writes her code, building in ways to handle error
“There must be separation between logic and error handling!”
Alas, there is no statement fairer
Some truth amid all the programmers’ rambling.

Don’t return null so you don’t have to check for null.
Don’t pass null into methods, unless you’re working with APIs.
Why spend another day slugging through code that is dull?
Why not focus your eyes on the grand prize?

Lest you want a code base that embodies dereliction,
Write a special case pattern to encapsulate behavior or throw an exception.

--

--