toddhunter
Member
Try to write code that is so clear in purpose that comments are redundant.
If you are considering writing a comment, consider if you could just pull the code out into a well named function, or if you could use variables to give names to the values you use.
Of course, you'll still need some comments, but far fewer. Most functions should not need comments.
Good advice. If you feel you need to comment something to explain why it works, then you are probably doing it wrong.
A very important form of comment though is to leave notes about "why" you changed something and when. That way somebody has a better chance of fixing what you broke (alway use somebody elses name of course).