Avoid Overly Repetitious Comments [DA1]

Avoid Overly Repetitious Comments [DA1]

Tip DA1

Many kinds of comments are valuable, but that’s not an excuse for going overboard and commenting everything. Excessive, redundant comments can have a negative impact in slowing readability and maintainability of code.

Overly repetitious comments just repeat the code in a slightly different way - they provide more to read without providing more information - and are best avoided.

There isn’t a magic formula for the right number of comments. Instead, focus on commenting efficiently - how to most effectively communicate what you need without giving a reader too much to read.

Make sure every comment adds value. If you find yourself individually commenting nearly every single line, that's probably a warning sign that something's off. There may be extraneous, overly repetitious comments or comments that could be combined in a concise way. Ask yourself, "What information does this comment provide that the code doesn't?" and tweak/remove comments appropriately.

The following examples show how some comments can be tweaked to communicate more than the code itself would concisely do:

Tap into your teams collective wisdom ad.png