The 5 Stages of Debugging Grief

Full article

I've spent enough time programming to know that a large chunk of the work most of us will ever do is debugging. We'll debug our own code, our team's code, some other team's code, the guy or gal who left our company 5 years ago's code, and that consultant who was paid 3x our salary while they spent a year changing the "New Hot App"'s architecture once a week's code.

If, like me, you find yourself in the middle of one of these fun debugging sessions, and all hope seems lost, keep your chin up! You may have to work through the five stages of debugging grief. Remember, there's always light at the end of the tunnel... wait, do you hear a train?


Start off by denying there even is a bug. After all, it works on your machine. Besides, it was reported months ago, and the codebase has changed several times. No way it's even a problem anymore!

I mean, what is a bug anyway, philosophically? Depending on your point of view, it almost looks like a... tilt your head a little... yeah, it's a feature! No? It's got some elements of a feature. There's code.. and coffee stains... maybe a certain level of dashed expectations.

Okay, the feature thing is up in the air, but it's definitely not a bug. Case closed!


Okay fine, the customer won't accept it as a feature. They updated the software and it happened again. The first thing you need to do is a git blame - it's incredibly important to know who to be angry at. Unless it ends up being you... then it was a faulty set of requirements to start with.

Oh good, it wasn't you! If it was, just keep moving further back in the commit log until you find someone who isn't you. If you created the file, move laterally until you find a file that's somewhat related with another name on it. Just keep going - it's completely normal to find that blame lies with the author of some framework you're using, the team behind Ubuntu, or even Charles Babbage for dreaming up the analytical engine in the first place.

Found a culprit, preferably one who can't argue? Nice! Of course, they either quit awhile back, never worked for your company, or died 150 years ago. The injustice! Stomp off to the coffee pot, vending machine, or just step outside for some fresh air.

Vaguely wonder why git blame doesn't have a --someone_else flag.


Unfair as life is, this problem has landed in your lap. Grab a cup of coffee or tea and promise yourself that if you focus you can have it done by noon. Realize it's 2pm and you still have no clue.

Just a couple more hours of hard work though, and you'll know exactly what happened and why! Okay, maybe 4 hours.. a whole day. You really needed a full day to understand it anyway, but now you just need a couple hours and you'll have it. Okay, a few more. Maybe another day. But you're so close... you can almost taste it. (Tasting code.. what was in that tea?)

Make one last deal with yourself - if you keep at it, this is unlikely to be the last thing you ever work on (though a nagging feeling is creeping up that you might be wrong).


Two days later, the world is making less sense than ever. You marvel that this code ever worked at all. In fact, there's no way it did. This isn't a bug - it's a catastrophe that's merely part of the larger disaster that is the application, which never had a chance anyway because all code is just awful.

By now, you're second-guessing the many decisions in life that led you to this moment, wondering how it is you're here when other developers are working at Google, sliding down a giant slide into their Jetsons-era pod chairs, eating free quinoa, and optimizing that single textbox that serves up their flagship application. Someone asks you about programming with stars in their eyes, and all you can muster is, "Programming? Don't talk to me about programming."


You mention in passing to someone on your team that you wish none of this had happened, and they assure you that so do all who live to see such times, but that is not for them to decide. All you have to decide is what to do with the time given to you - which is like one more day for this bug.

You begin to accept that this is your fate in life. Decades from now, you'll explain to your grandkids how this one issue consumed the best years of....... wait a second.

Why didn't you notice that before? Right there, line 712 of the 42nd class in the 13th module? Oh man, that's so obvious now that you've seen it! Of course it was a problem. One quick fix, one PR, and one problem solved. Nothing to it!

Oh look, you've got a new email. Someone just reported a bug.


Grant Winney

I write when I've got something to share - a personal project, a solution to a difficult problem, or just an idea. We learn by doing and sharing. We've all got something to contribute.

Comments / Reactions

One of the most enjoyable things about blogging is engaging with and learning from others. Leave a comment below with your questions, comments, or ideas. Let's start a conversation!