Code Quality
- Use very descriptive names. Be consistent with your names.
- A function should not do more than one thing.
- SRP (Single Responsibility Principle): a class or module should have one, and only one, reason to change.
- Stepdown rule: every function should be followed by those at the next level of abstraction (low, intermediate, advanced).
- A long descriptive name is better than a short enigmatic name. A long descriptive name is better than a long descriptive comment.
- 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.
- 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.
- 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.