- Explicit is better than implicit
- Employ loose coupling, high cohesion
- Favor composition (has-a) over inheritance (is-a): Use mixins, interfaces, and protocols, abstracts, and related structures to keep class hierarchies flat.
- Favor declarative programming over imperative programming.
- Don’t trade readability for write-time convenience. Code is meant to be read.
- Adhere to the SOLID principles.
- Database tables should be in third normal form or greater.
- Go with the option that’s more testable if ever in doubt.
- Use design patterns but don't be a slave to them.
- Avoid greater than 3 levels of nesting all around. This goes for project folder structure, overlays in user interfaces, inheritance hierarchies, sitemaps, etc.
- Follow agreed upon best practices and terminology of each unique tool, framework, or library.
- Follow a style guide (PEP8, AURORA ESLint, etc.)
- Don’t reinvent the wheel, but be cautious when introducing libraries.
These principles are a compass not a roadmap. Always use good judgement.
Definitive Guide to Modeling Polymorphism
Avoid Django's GenericForeignKey
Modeling Polymorphism in Django