CC2e
Login | Register Construx Home
Code Complete, Second Edition
Chapters: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 28 29 30 31 32 33 34 35
   Contents Chapter 32 Checklist: Good Commenting Technique

Chapter 32: Self-Documenting Code


General

  • Can someone pick up the code and immediately start to understand it?
  • Do comments explain the code's intent or summarize what the code does, rather than just repeating the code?
  • Is the Pseudocode Programming Process used to reduce commenting time?
  • Has tricky code been rewritten rather than commented?
  • Are comments up to date?
  • Are comments clear and correct?
  • Does the commenting style allow comments to be easily modified?

Statements and Paragraphs

  • Does the code avoid endline comments?
  • Do comments focus on why rather than how?
  • Do comments prepare the reader for the code to follow?
  • Does every comment count? Have redundant, extraneous, and self-indulgent comments been removed or improved?
  • Are surprises documented?
  • Have abbreviations been avoided?
  • Is the distinction between major and minor comments clear?
  • Is code that works around an error or undocumented feature commented?

Data Declarations

  • Are units on data declarations commented?
  • Are the ranges of values on numeric data commented?
  • Are coded meanings commented?
  • Are limitations on input data commented?
  • Are flags documented to the bit level?
  • Has each global variable been commented where it is declared?
  • Has each global variable been identified as such at each usage, by a naming convention, a comment, or both?
  • Are magic numbers replaced with named constants or variables rather than just documented?

Control Structures

  • Is each control statement commented?
  • Are the ends of long or complex control structures commented or, when possible, simplified so that they don't need comments?

Routines

  • Is the purpose of each routine commented?
  • Are other facts about each routine given in comments, when relevant, including input and output data, interface assumptions, limitations, error corrections, global effects, and sources of algorithms?

Files, Classes, and Programs

  • Does the program have a short document such as that described in the Book Paradigm that gives an overall view of how the program is organized?
  • Is the purpose of each file described?
  • Are the author's name, email address, and phone number in the listing?


Other Code Complete Resources:

See Also: