guides:programstyle:comments
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:programstyle:comments [2020/08/18 11:36] – [Comment Contents] wikiadmin | guides:programstyle:comments [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 103: | Line 103: | ||
cout << endl; // done with output, print an endl | cout << endl; // done with output, print an endl | ||
</ | </ | ||
+ | |||
+ | Use comments to supplement the understanding of major sections of code. Only rarely should comments be used on every line of code. The following is not an acceptable use of documentation. | ||
+ | <code c++> | ||
+ | // Get the noun from the user | ||
+ | noun = GetWord(" | ||
+ | // Get the adjective from the user | ||
+ | adjective = GetWord(" | ||
+ | // Get the action verb from the user | ||
+ | actionVerb = GetWord(" | ||
+ | </ | ||
+ | |||
+ | The code above is mostly self documenting due to identifier choice, so a single comment would be more appropriate | ||
+ | <code c++> | ||
+ | // Get the words from the user | ||
+ | noun = GetWord(" | ||
+ | adjective = GetWord(" | ||
+ | actionVerb = GetWord(" | ||
+ | </ | ||
+ | |||
Finally, most comments in code should employ a c++ style line comment. | Finally, most comments in code should employ a c++ style line comment. |
guides/programstyle/comments.1597750607.txt.gz · Last modified: 2024/07/25 15:01 (external edit)