UA-5095748-1

Wednesday, January 23, 2008

Must step through every line of code

The interactive debugger is probably the one of greatest invention for programmer productivity. It's right up there with high level languages, and OO design. You don't realize the importance until you had to give it up. Few years ago, I had to do some very low level C / assembly programming. I'm talking about no RAM, no OS, only 64 8 bit registers for memory, and 4k of ROM. Interactive debugger would have been a dream come true, heck, I would have happy with printf. Instead, I had 8 little flashing LEDs that I had to count. Crazy.

All good developers know that they should execute through every line of code they write. The code is working only when I see it working inside a debugger. Seeing is Believing.

One of my favorite programming practice is to set the breakpoints as I write the code or when I review the code after it's finished. I don't set the breakpoints on every line, however I set it at the beginning of every branch in the code. As each breakpoint kicks in, I verify the code is correct then clear it. After a few execution of the test codes, I visually see all the uncleared breakpoints. Any uncleared breakpoint shows where my test cases are inadequate. How awesome is that!

Using this technique ensures that I have stepped through every line in the code. Uncovered missing test cases. Performed all the positive and negative testing. This is made possible because of a integrated IDE and interactive debugger. Interactive debugger is truly one of the greatest invention for programmers productivity.

No comments: