Friday, July 10, 2009

Debug it! A Book on Software Debugging

Having known Paul Butcher as someone who was into software sales, it came as a pleasant surprise to see his new book on software debugging: "Debug It! Find, Repair and Prevent Bugs in Your Code". I finally got around to reading it last weekend. I was amazed by his depth of wisdom in software debugging. While most would say, "why debug, if you write code correctly?", software defects are an inevitable and unfortunate part of life. Recent evidence proves that on the average for every 8 lines of code a programmer writes, there is one defect. The defect rate does not vary much by how a expert a programmer is.

The book has a number of gems of wisdom on not only "how to fix" but also on "how not to fix" defects. Here is one of those from the book which most of us have have across at some time or the other:

int process_items(item* item_array, int array_size) {
int i;
/* For some reason array_size is off by one, so fix it up here */
array_size++;
for(i = 0; i <>
Process item_array[i]
}
}

A lot of times programmers find quick solutions to problems, and "make the bug go away", hopefully forever. Frequently not, but instead creating another defect in the process, somewhere else in the software. His recommendation of the need to always critically analyze the defect even after it is fixed is extremely relevant: "How did it ever work before?". Careful reflection, even at this stage can often provide clues and further insights not only to the defect that was fixed, but possibly finding other hidden defects too.

I also found his section on the need for automated testing very relevant in today's product development. Though some companies use that very effectively others do not invest in any automated testing. The author has also provided a good list of current popular software tools all the way from source control systems, bug tacking systems, to logging and testing tools and libraries.

Altogether the book is an easy read, with the author's flowing style. But like his recommendation on reflection after fixing a bug, the reader learns a lot more if he takes a break to reflect after every few pages he reads. Someone who was in the trade of developing software for a a few years, would readily identify with many of the gems in this book. This is a recommended read for anyone who works closely in the software industry, be it a developer, a tester or even a product manager.

No comments: