I am having an ambivalent reaction to fixing a bug that has been resisting me for the last nine months.
Of course it’s immensely satisfying to have a result from the many hours that I’ve spent in the debugger chasing it down. Debugging is like a scientific research product (not that I’ve ever done one of those). As you acquire more data, a picture slowly emerges. Hypotheses suggest themselves, and are tested and rejected, or accepted and become the basis of another layer of hypotheses. The process that your bug is a small part of, which may be completely obscure and unfamiliar when you begin working, becomes intimately familiar to you. In extreme cases, you may even dream about it.
By the way, I have never had a Kekulé-like experience and fixed a bug in a dream, but more than once I have found a fix by taking a smoke break. During the debugging process, with my face deep in the details, I often fail to think things through and make deeper connections, but when I stop debugging, get out into the fresh air and think about something else for a few minutes, a solution will often just pop into my mind, seemingly out of nowhere.
You may be in doubt about the value of the possible solutions that you experiment with early in this process, but once you are totally “in the zone” and living and breathing the code, you have no doubts. If your fix is hacky, you feel low, even unclean (though you may accept it out of frustration), but if you discover the One True Fix ™, it will shine out of the screen at you like the Holy Grail. My wife says that she can tell when I have fixed a bug just from the tone of my voice when I pick up the phone, or by seeing the way I walk out of the office.
However, the fact is that last night I felt a bit let-down. Maybe it’s the lack of anything substantial produced by all this effort. In the amount of time invested in fixing this bug, I could probably have written a book, designed a cathedral, or produced a play. Instead of that, I have produced one line of code, and no special new or cool functionality that I can point to in the program. It just does what it should have done all along.
And maybe on some level I’m sorry to say goodbye to the bug that I’ve come to know so well. It’s like splitting up with a partner — even if you know that the relationship was wrong for you and you are better off apart, there is always some sensation of regret.
Or maybe there’s some significance to the nine months that this bug has existed. Could I be suffering from post-natal depression?