4 Reasons to Leave a Code Comment Subscribe to my feed

written by Max Chernyak on 20 Jul, 23

I originally wrote this list as a part of Writing Maintainable Code is a Communication Skill, then made a tweet. Since then, I had to link this list multiple times. This post makes it easier to link.

Reasons

  1. An odd business requirement (share the origin story)
  2. It took research (summarize with links)
  3. Multiple options were considered (justify decision)
  4. Question in a code review (answer in a comment)

Important caveat for number 4: if your code can be restructured in a way that answers the question without a comment, do that instead.