Write Comments at a Higher-Level of Abstraction Than the Code Itself [DL1] [WHAT]

Write Comments at a Higher-Level of Abstraction Than the Code Itself [DL1] [WHAT]

Tip DL1

Comments that simply repeat the code aren’t helpful - they give more to read without giving more information. Comments should enhance the code, not restate the code in an inferior way. Therefore, write comments at a higher level of abstraction than the code itself.

Exactly what that higher level of abstraction is can vary depending on the kind of comment you’re writing, but always aim to write comments to communicate more to readers in an easier-to-understand way.

The following examples show how low-level comments (at about the same level of abstraction as the code itself) can be transformed into higher-level comments:

 

Find the experts Ad.png