DEV Community

Discussion on: Writing Better Code

Collapse
 
codemouse92 profile image
Jason C. McDonald

YES!! Best summary of these techniques I've read yet, and nary a "all comments are errors" assertion to muck it up.

While I'm an advocate for intent-commenting (and I think I accidentally coined the phrase "comment why, not what"), I'm also pretty vocal about the corollary: never send a comment to do a name's job.

Right along with that, as you said, if you need a comment to know what the code is doing, the code is probably in sore need of a refactor. Or as Tim Peters puts it, "If the implementation is hard to explain, it's probably a bad idea."