Monday, January 21, 2019

Comment Before You Finalize Your Code

Joke about commenting code.
I've often heard programmers say, "Why should I bother commenting my code now? It'll only change!" We comment code to make the software easier to debug, test, and maintain. By commenting your code while coding (or beforehand), it will be easier for you to debug the software.
    As you debug your software, you will undoubtably find flaws. If a flaw is in your conversion from the algorithm to the code, you'll need to change only the code, not the comments. If the flaw is in your algorithm, you'll need to change both the comments and code. But how would you even know you had an algorithmic error unless you had comments?


Reference:
Kernighan, B., and Plauger, P., The Elements of Programming Style, New York: McGraw-Hill, 1978.