User Tools

Site Tools


en:devmon:guidelines:20bestpractices

20 Best Practices

  1. Correctness, simplicity and clarity come first.
  2. Avoid unnecessary cleverness. If you must rely on cleverness, encapsulate and comment it.
  3. Avoid duplication (DRY).
  4. Coupling and Cohesion. Systems should be designed as a set of cohesive modules as loosely coupled as is reasonably feasible.
  5. Data hiding. Minimize the exposure of implementation details.
  6. Minimize the scope of variables, pragmas, etc..
  7. Establish a rational error handling policy and follow it strictly.
  8. Interfaces matter. Once an interface becomes widely used, changing it becomes practically impossible (just about anything else can be fixed in a later release). Design the module's interface first.
  9. Design interfaces that are: consistent; easy to use correctly; hard to use incorrectly; easy to read, maintain and extend; clearly documented; appropriate to your audience. Be sufficient, not complete; it is easier to add a new feature than to remove a mis-feature.
  10. Write components that are testable in isolation.
  11. The result of every file operation or API call or external command should be checked, and unexpected results handled.
  12. Use descriptive, explanatory, consistent and regular names. (see variables)
  13. Avoid magic numbers.
  14. Don't optimize prematurely. Benchmark before you optimize. Comment why you are optimizing.
  15. Agree upon a coherent layout style and automate it. (see tidy)
  16. Adopt a policy of zero tolerance for warnings and errors. Tools such as Perl::Tidy and Perl::Critic can help here.(see tidy)
  17. Commenting: prefer to make the code obvious; don't belabor the obvious; comments describe what and why not how.
  18. Separate user vs maintainer documentation.
  19. Use a revision control system https://github.com/bonomani/devmon and single-step automated build/test.
  20. “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live” (Damian Conway)
en/devmon/guidelines/20bestpractices.txt · Last modified: 2021/08/19 07:29 by adminw1k1