Lesson 113 +10 XP

Comments and Style

Comments and Coding Style

Good code has clear comments, names, and consistent formatting.

Two syntaxes

// single line
/* multi
   line */

Naming conventions (common)

  • Variables & functions: lower_case or camelCase.
  • Constants: UPPER_CASE.
  • Struct type names: PascalCase.

Comment the why, not the what

int offset = 12;  // skip the 12-byte header

Style rules

  • One statement per line.
  • Consistent indentation.
  • Space between keywords and brackets.
  • Brace style: match the codebase.

TL;DR

  • Use // for daily notes, / / for blocks.
  • Consistency matters more than the specific rule.
  • Comment the why, not the how.
  • Keep names descriptive and short.