Skip to content

Instantly share code, notes, and snippets.

@Pharap
Created October 11, 2019 02:06
Show Gist options
  • Save Pharap/8658f64266a65b2741fdb3c9841f1997 to your computer and use it in GitHub Desktop.
Save Pharap/8658f64266a65b2741fdb3c9841f1997 to your computer and use it in GitHub Desktop.
A list of so-called 'programming sins'

Programming Sins

  • Magic numbers
    • Constants with a specific meaning should be clearly named
    • Possible exceptions include:
      • 0, 1 and 2 where usage is unambiguous
      • arguably the shift and mask values when doing bitshifting and masking
  • Single-letter variables names
    • With the possible exceptions of:
      • x and y for coordinates
      • maybe i and j for loop counters
  • Using contractions in variable names
    • E.g. cnt for count, idx for index
  • Using + to combine bitmasks instead of |
  • Mixing brace styles
  • Mixing tabs and spaces for indentation
    • Using tabs for indentation and spaces for alignment is perfectly acceptable, though whether you should be aligning your code is more contentious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment