September 11, 2003
Explanatory Debugging
Why wasn't it working?
I had visually checked my code, stepped through it with the debugger, tried thinking laterally. But could I find the cause of the problem? No. I had to admit it, despite having given it my best effort, the answer had so far eluded me.
When one is at the point of pulling one's hair out (and one is follicularly challenged on top), it is time to ask for help.
So I began explaining the problem to my colleague, showing him the code executing in the debugger. Within a couple of minutes I had spotted my problem - essentially a typing mistake when specifying the name of an attribute that I was setting in an HttpSession object.
Argh!!! Why hadn't I spotted the mistake when I was investigating on my own?
It's not the first time I've experienced this. As my colleague suggested, it is most likely due to the different parts of the brain used to explain something to another person, compared with those used in solitary thought. When one is thinking alone it is so easy to make false assumptions, isn't it?
The other aspect of this experience that comes to mind is the practice of Pair Programming (as opposed to Purr Programming) proposed by XP. One of the benefits is that two pairs of eyes are better than one so that simple typing mistakes are likely to be detected as they are made rather than much later.
I know there are good reasons why Pair Programming may not always be appropriate, but I think the lesson is to more often call on someone else to help out briefly, rather than expend a lot of effort in isolation without making progress.
Posted to Peopleware, Software Development by Keith PittyThere is a saying, "if you can't explain it to someone else, you don't understand it." Very true.
Posted by: Yuri at September 11, 2003 5:17 PM
