

Ask HN: Any resources to learn how to effectively use commenting? - rankam

The Minecraft clone in C thread a couple of days ago had a discussion about commenting and it got me thinking about the fact that I don&#x27;t know how to effectively use comments while writing code (I&#x27;m mostly self-taught and don&#x27;t work for a tech company, yet). Does anyone have any tips or know of good resources where one can learn this?
======
emilga
"Clean Code" by Robert C. Martin may be what you're looking for.

Basically: express yourself in code. If you feel that some part of your code
needs commenting, ask instead if it's possible to rewrite the code so that it
is self explanatory. (The book goes into much more detail about this and more,
of course.)

Example of "bad" code:

    
    
      // days since initialization
      int d;
    

Better code:

    
    
      int daysSinceInitialization;

~~~
rankam
Excellent! Thanks - I'll definitely check it out!

