Blog‎ > ‎

Programming Principles

posted Jan 28, 2015, 10:29 PM by Taylor Peterson   [ updated Jan 28, 2015, 10:29 PM ]

  • Blocks inside conditionals and loops should preferably be one line long and have descriptive names to improve readability and self-documentation
  • Limit the number of arguments to functions (0 is best; flags are terrible)
  • Comments are crutches for unclear code
  • Only the code is guaranteed to be true - code should be its own documentation
  • Replace comments with a function name that says the same thing
  • No need for comments in non-public methods/classes - you can just look at the code itself
  • That said, comments can be useful for informative explanation of intent, amplification of important, API documentation, etc. 
  • Write tests to learn API's (bonus: documentation & feature checking)