DEV Community

Discussion on: Why Code Comments Still Matter

Collapse
 
mtbsickrider profile image
Enrique Jose Padilla

My 2 cents after reading Clean Code by Robert Martin and 2 years of experience.

TLDR: Minimize comments except for WHY questions.

Whenever i feel the urge to comment, I look at my code and try to think as if i never have seen it before. I generally have a checklist.

  • Is my naming verbose and clear
  • Am i mixing levels of abstraction in my function, can i make it smaller by breaking it up.
  • Am i using magic numbers
  • Will reading this comment allow the user to be more productive
  • Is the comment tightly coupled to the LOC

There's probably a couple more, but those are top of my head.

100% i comment for WHY. These tend to be exceptions that at first glance seem wierd to anyone who didn't see when it broke.