Sometimes we act as if bugs just appear in our code on their own, but we all know that’s not true. The bugs in my code were written by me. I didn’t mean to write them. I didn’t want to write them. But I did anyway.
I remember when I first heard Al Shalloway refer to a bug as code he had written and it hit me, I’m the author of the bugs in my code. There was no one else to blame but me.
Many teams I meet hoard bugs. Instead of heeding the message that bugs are telling us or fixing them as soon as they are found, they collect them, track them, and tell themselves that someday they’ll get rid of them.
Hoarding bugs is demoralizing, and their numbers just grow and grow until there are so many bugs it becomes uneconomical to address them so they either learn to live with most of them or the bugs pull their project under. Neither of these are good outcomes.
Bugs are often the tip of the iceberg, they’re the harbinger of something much worse to come, a warning sign that things are headed awry. We must heed these warnings and not ignore them.
Bugs can hide and finding them can often be the hardest part of getting rid of them. My friend Llewellyn Falco says that finding a bug in a large program is like being told there’s a misspelled word in a dictionary. Fixing a misspelled word is easy, finding the misspelled word can be time consuming and tedious.
In the TV show Mr. Robot, eps1.2_d3bug.mkv, Elliot says, “Debugging is actually all about finding the bug. About understanding why the bug was there to begin with. About knowing that its existence was no accident.”
I love this quote and I say something very similar in my new book, Beyond Legacy Code: Nine Practices to Extend the Life (and Value) of Your Software. On page 26, I write:
I’ve been dealing with bugs for many years as a developer, but I’ve only recently started to see them for what they really are: flaws in my software development process.
And like insects, software bugs need the right conditions to breed.
Bugs don’t just happen, we let them happen. And we have the power to stop them. If we don’t then they can get out of hand.
But it doesn’t have to be that way. Instead of hoarding bugs or hating bugs we can recognize them for the messengers they are and heed their message to get back on track. Every bug is a missing test, a critical distinction I failed to realize. If I can see this then I can not only fix that one bug but vanquish a whole class of bugs. If I can see a bug for what it truly is then it becomes my teacher and I become its grateful student.