Thursday, May 27, 2010

Commando-cleaning casualty

Ever been in such a rush to clean the apartment/house/dorm up that you were too effective in getting stuff out from underfoot--meaning that you couldn't find anything you needed later? How many times did you go to the usual place to find something in particular before you broke down and went on closet-safari until you found it?

The sad thing is, this can happen in programming as well. In the process of cleaning completely extraneous/pointless variables from a web page (and herding most of the variable declarations into one place b/c they were sprinkled ad-hoc throughout the page), I accidentally made a function variable global. A recursive function variable, no less. Whoops. (If you have no idea what that means, suffice it to say that the web page basically freaked out for no apparent reason.)

Problem was, during debugging I utterly missed the fact that the (misplaced) variable declaration had moved, simply because I was so darned used to seeing it in its rightful location. By all rights, the (figurative) head-banging and ultimate forehead-slap should have registered on the Richter Scale.

All of which demonstrates that the line between maintaining good (code) hygiene and commando-cleaning can sometimes be only a few pixels wide. Just like in regular life.