9 Living with bugs

 

This chapter covers

  • Error handling best practices
  • Living with bugs
  • Intentional error handling
  • Avoiding debugging
  • Advanced rubber-duck debugging

The most profound work of literature on bugs is Metamorphosis by Franz Kafka. It tells the story of Gregor Samsa, a software developer, who wakes up one day to find out that he is actually the only bug. Well, he isn’t actually a software developer in the story because the entire practice of programming in 1915 only consisted of a couple of pages of code Ada Lovelace wrote 70 years before Kafka wrote his book. But Gregor Samsa’s profession was the next best thing to a software developer: he was a traveling salesperson.

Bugs are basic units of metrics for determining software quality. Because software developers consider every bug a stain on the quality of their craftsmanship, they usually either aim for zero bugs or actively deny their existence by claiming that it works on their computer or that it’s a feature, not a bug.

9.1 Don’t fix bugs

9.2 The error terror

9.2.1 The bare truth of exceptions

9.2.2 Don’t catch exceptions

9.2.3 Exception resiliency

9.2.4 Resiliency without transactions

9.2.5 Exceptions vs. errors

9.3 Don’t debug

9.3.1 printf() debugging

9.3.2 Dump diving

9.3.3 Advanced rubber-duck debugging

Summary