Code Quality

  1. Use very descriptive names. Be consistent with your names.
  2. A function should not do more than one thing.
  3. SRP (Single Responsibility Principle): a class or module should have one, and only one, reason to change.
  4. Stepdown rule: every function should be followed by those at the next level of abstraction (low, intermediate, advanced).
  5. A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment.
  6. The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very special justification and then shouldn’t be used anyway.
  7. Flag arguments are ugly. Passing a boolean into a function is loudly proclaiming that this function does more than one thing. It does one thing if the flag is true and another one if the flag is false.
  8. Write learning test when using third-party cody to make sure it behaves the way you expect it to. And if codebase changes in time, at least you find out early enough.