DEV Community

Discussion on: Code comments are (mostly) a violation of DRY

Collapse
 
eljayadobe profile image
Eljay-Adobe

Explanatory prose is a good comment. Explain the why and how something complex is put together. Future programmers can then more readily understand why something was done, and if that rationale is still applicable.

Comments that just re-iterate what the code is doing are useless comments. Assuming (next point)...

Code that uses good names such that it needn't be commented at all is better than code that uses unhelpful names, and necessitate commenting what the poor code with non-descriptive names is doing.

Comments that do not jibe with what the code is doing are more-than-useless, because the future programmer will be puzzled if the comment is correct and the code is broken, or the code is correct and the comment is outdated and/or specious.