Fact: you can make your life a whole lot easier, when debugging, simply by not making assumptions - by guessing, essentially - about what might be at fault. Concentrate on what you can see and what you know to be true - or what you can find out by directly querying the system. (Really, this applies to any kind of problem solving, in any walk of life.)
I often forget, and that's why I'm making a point to bring it up now. As a means of drumming it into my own thick head. Only last week, in a moment of weakness, I fell into the trap of assuming I knew the cause of a problem I was having. The curious thing is that when I discovered that my initial assumption was wrong, I went and replaced it with another, equally invalid one. And so my fate was sealed. I might just as well have packed it in then and there, but instead, I spent Lord-knows how long flitting aimlessly from one source-file to another. I was blinded by my assumptions: I couldn't see the wood for the trees. Worst of all, they were the wrong trees in the wrong forest.
I wonder, actually, how I came to find the source of the problem on that occasion. I'm guessing it was the result of a kind of brute-force attack on my subconscious: I must have fully memorized the entire section of code after the 80th reading, pieced it together somehow, and then - thank God - had an epiphany. I clearly remember, afterwards, thinking that I'd looked at the block of code that would have quickly led me to the fault, but because I thought I already knew what the cause was, I didn't take the time to really look at the lines in front of me. My mind was closed-off and wandering elsewhere. You don't want to know the awful feeling you get after wasting hours tracking down a bug that insignificant.
Even if you find yourself in the middle of such a predicament, there's still hope. Take a break. Give yourself 30 minutes, say, and if, at the end of that, you still haven't had any success, get a change of scenery. Better still, seek help from a colleague. There have been countless times when I've been in the middle of explaining a problem to my buddy, and I've spotted the cause. By explaining a problem, by breaking it down for another person to understand, you're forced to confront the facts. Sometimes that's all it takes. And if they can't help, at least you'll be in the right mindset.
And don't go thinking that it's safe to take a stab at the answer because a problem looks simple. Remember that one problem can often turn out to be the work of a whole gang of pesky little bugs. If you go into a fight like that without an open mind, you're gonna be in for a world of pain.
October 23, 2008
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment