📜 ⬆️ ⬇️

The most valuable programming advice I received

“A year or two, since I started working at Bell Labs, I was working in tandem with Ken Thompson on an interactive graphic language developed by Gerard Holzmann. I typed faster, so I sat at the keyboard, and Ken stood behind me. We worked quickly, and when the compiler gave an error, I reflexively started digging into the problem, studying the call stack, the output of the program, running the debugger, and so on. But Ken just stood by and thought, ignoring me and the code we just wrote. Soon I noticed a pattern: Ken often understood what the problem was, and before I said: “I know what’s wrong”. Usually he was right. I realized that Ken was building a mental code model, and when something broke, it was a mistake in the model. And thinking about how this problem could arise, he found out where the model was wrong or where our code could incorrectly reflect this model.

Ken taught me that thinking before debugging is extremely important. If you start to dive into an error, you are more likely to fix a local problem in the code, but if you first think about the error, how it could occur, you will find and fix a higher level error in the code, which will improve the architecture and prevent the appearance of similar errors. mistakes in the future.

I understand that this is more a matter of style. Some insist on line-by-line debugging of everything in the world with specialized tools. But now I believe that thinking without looking at the code is the best debugging tool, because it leads to better software. ” - Rob Pike
')
Source - InformIt .

Source: https://habr.com/ru/post/150125/


All Articles