Tip of the day, #37
Debugging. Part III. An ounce of prevention... Take a building-block approach. Start with the really simple stuff, then use those things as components to build or debug more advanced components, and so on. The job is only complicated if you don't break it down into manageable chunks, conquer them, and then put them together in steps. Working for small, low-budget outfits, I have found that the lack of expensive debugging tools actually teaches you to write better code. You can't have the attitude that "I'll whip out this code in record time and debug it later." Out of necessity, I've become more structured and neat in my programming, documenting everything thoroughly, making the code as readable as I know how, and proofreading. Large companies are finally starting to see the value in this, and the industry magazines have recently had some articles on code inspection and having committees of the programmers' peers proofread the code. I sometimes catch bugs when further commenting code that's already working but not exhaustively tested yet. I comment as if trying to explain it to someone else who hasn't been following my train of though on it. (If I come back to change it a year later, I'll need the comments anyway.) As a result of this madness, no user has ever found a software bug in any product or automated test equipment I programmed. The projects have had from 700 to 10,500 lines of code. BTW, using a lines-of-code-per-day benchmark of programming performance is a sure way to end up with inefficient, buggy code that's hard to figure out and fix or modify later. I once worked with a programmer who typed non-stop. I always wondered what he was typing. After he left the company, I had to fix a 4-page routine he wrote. When I was done, it was down to a half page, bug-free, clearer, faster, and did more with less memory. (Eventually most of what he wrote had to be redone.)
_________________ http://WilsonMinesCo.com/ lots of 6502 resources The "second front page" is http://wilsonminesco.com/links.html . What's an additional VIA among friends, anyhow?
Last edited by GARTHWILSON on Wed Feb 22, 2012 9:13 am, edited 1 time in total.
|