Clean coding principles

Avatar
363 followers
Oct 21, 2024

Do you follow these 0:00 clean coding principles?


  1. 0:03 Eliminate if/else branching, use early termination
  2. 2:18 Ambiguous definitions: “is” function prefix clearly returns booleans
  3. 4:06 Self-documenting code, avoid belaboured comments
  4. 5:39 Consistent formatting, use Eslint + Prettier to automate code style
  5. 7:16 DRY (don’t repeat yourself), look for opportunities to refactor, make sure to test
  6. 8:40 Fail or exit functions fast, related to 1 above
  7. 9:31 Avoid magic values, declare and use constants instead
  8. 10:43 Avoid violating single responsibility, use pure functions with no side effects
  9. 11:57 Overly clever code (code golf) leads to impenetrable single liners, need to rewrite to debug
  10. 14:04 Premature optimisation