Daily Archives: March 12, 2008

Debugging with fish

Someone needed a report tweaking at work; no problem, except it was something someone else (long since gone) had originally written. Still, it’s a fairly simple report, tra la la, open the source code, this makes sense, there’s even a comment or two, tinker tinker, add an extra bit here, and then… Y’know when you’re on a rollercoaster, and you’re thinking “hey, this isn’t so bad”, and then you realise the car hasn’t actually started moving at all, and then it does and you’re PLUNGED OVER THE PRECIPICE OF TERROR? In the source code equivalent, all the comments suddenly vanish, and there are do loops inside for loops inside while loops and there are 38 variables being assigned and reassigned that were probably logical enough when only three were needed so they start as x, y and z, except then the original coder realised they needed more so you get w, v, u working back through a (except missing out l, possibly for a hugely significant reason but more likely they got distracted in the middle of working backwards through the alphabet), and then they ran out of single letters so you get random abbreviations that might or might not relate to what’s being stored in the variable in question…

Time for Advanced Debugging Technique 1, then: output random gibberish all over the place. Being a speaker of Commonwealth Hackish, “fish” is my preferred metasyntactic variable and random output of choice. Course, when just using “fish” it gets difficult to tell whether “fishfishfish” is the same fish looped three times or three different fish, so complex debugging requires many different types of fish. At the height of debugging, the report looks something like:

HakeBreamMackrelTotal Number of WidgetsHaddock

TunnyJanuary: SturgeonSturgeonSturgeon37
TunnyFebruary: SturgeonSturgeonSturgeonSturgeonSturgeon22

With sufficient fish, I eventually work out what’s going on, and make the requisite changes. The difficult bit of Advanced Debugging Technique 1 is then removing all the fish references from the code, as people are inexplicably confused by the appearance of random sturgeon in their reports. I’m fairly sure I caught most of them, but if someone makes a particular set of selections after 9pm on a Wednesday in a month with more than six letters, I might be getting a support call inquiring about a large quantity of hake…