The most valuable advice on programming that I received
A couple years ago, I worked together with Ken Thompson on the interactive graphics language that was developed by Gerard Holzman in Bell Labs. I was typing quicker, therefore, I sat at the keypad, and Ken stood behind me. We worked quickly and when the compiler gave out an error, I started reflexively digging in a problem, studying the call stack, program output and launching a debugger, and so on. But Ken simply was standing nearby and thinking, ignoring me and a code, which we just wrote. Soon I noticed regularity that Ken often understood the problem faster than me and was saying, “I know, what is going on”. Usually, he was right. I understood that Ken built the mental model of a code, and when something was broken, it was the error in this model. He was thinking of how this problem could arise, so he explained what was wrong with model, or where our code could mirror this model incorrectly.
Ken taught me that it is extremely important to think before debugging. If you start plunging into the error, probably, you will fix a local problem in the code. But if you think of the error at first, you will find and correct the error of higher level, and that will allow improving architecture in the code and preventing appearance of similar errors in the future.
I understand that is the style issue. Some people insist on line-by-line debugging using the specialized tools. But I believe now that thinking without looking in the code is the best debugging tool, because it leads to the best software.
|Vote for this post
Bring it to the Main Page