Wednesday, November 5, 2008

On Debugging

Note to future self: there are two ways to debug. Know when to switch.

Alpine Style
The vast majority of debugging can - should - be done this way. When climbing a mountain "Alpine-style", one carries the bare minimum of gear, and moves as quickly as possible to the summit and back; a sort of vertical sprint.

Siege Style
Alpine-style mountaineering works well on the great peaks of Western Europe; conquering the great peaks of the Himalaya required a different approach. Huge teams traveling with equipment loads measured in metric tons treated peaks like K2 and Everest as natural citadels, fixing ropes and ladders up the ramparts, inching a string of camps with infinite care and labour towards the summit.

Everest: a classic "Siege" target. Photo: Pavel Novak

If a day of simply strolling a debugger through suspicious methods doesn't work out, it is time to switch tactics - whatever the behavior of the defect is, it is too complex to be easily followed. Stop expecting easy insights, and instead instrument anything potentially relevant with log files or console output. Keep an open mind: after all, if you haven't spotted the cause already, anything is possible.

p.s. This is also be a good time to improve your unit tests

No comments: