4 ms·
At the risk of sounding tautological I will say that good comments are good and bad comments are bad. Code of which it is unclear why it is the way it is should
by cjfd 3y ago
At the risk of sounding tautological I will say that good comments are good and bad comments are bad. Code of which it is unclear why it is the way it is should be commented. Any sort of rule that comments should be written in certain places, e.g., 'comment every public method' train people to write useless comments. In a way writing a comment is an admission of loss. I have failed to write code that was clear enough, so now I have to add a comment. Most code is quite straight forward. As a rule of thumb if you have some code that is neither highly complex nor very straightforward maybe a comment is needed once every one hundred or two hundred lines.
- DarkNova6 3y agoI'm thinking the same. I'm going so far and in most cases say "No comments in method bodies" in Merge Reviews. Why? Typically, you are explaining statements with a comment. This is code which becomes self-documenting once you turn it into a method with a good name. Every tricky bit can now be documented via JavaDocs as well (and other language equivalents). This also tends to avoid having 200+ line methods as well :D