Comments rules 注释原则

  1. Always try to explain yourself in code.

  2. Don't be redundant.

  3. Don't add obvious noise.

  4. Don't use closing brace comments.

  5. Don't comment out code. Just remove.

  6. Use as explanation of intent.

  7. Use as clarification of code.

  8. Use as warning of consequences.

  • 尽可能使用代码解释(自解释)。

  • 避免多余的注释。

  • 不为添加显而易见的代码加注释(噪音)。

  • 无须为一个代码块结束时的右括号添加注释。

  • 无用的代码直接删除,不要注释。版本控制系统会保存一切。

  • 用注释解释代码的意图。

  • 用注释澄清代码。

  • 用注释提示代码后果。

Last updated

Was this helpful?