6 Ways to use Code Comments effectively
When you are learning to code it almost always follows the path of spaghetti-code. But, there is one magic bean you can use in your code which will make your life easier when you look back at your own code (or someone elses') 10 years later.
I haven't been coding for 10+ years but all these years that I've looked at or got a chance to work on someone else's code, proper meaningful comments made my job way more productive than any other tool that I've come across. Because, good comments tell us WHY the code is that way. While the code itself tells me what it is doing.
Following are sort of best practices/guidelines for good comments. If your code is self explanatory, by all means, forget about commenting. But, if there is at least one shady magical piece of work that your code is doing, you might want to think about adding proper comments on them. Please note that this is by no means a full list of guidelines but rather a short and sweet version.