Related: Programming MOC, Concepts MOC


Info

Clean code are good coding practices. I’m writing them down with examples as I come across them myself.

Read Clean Code by Robert J Martin !

Naming Variables

  • Meaningful names: avoid comments to explain what the variable is.
    • instead of var d; // elapsed time in days, use var elapsedTimeInDays
  • Disinformation/Misnomers: some common spoken words mean something specific in coding, like “list”
    • instead of var accountList = [ ], you can just use accounts = [ ]

Functions

  • Keep them small and doing one thing: “They should really be 20 lines long. The longer a function gets, it is more likely…to do multiple things and have side effects.”

Other