Principles
Universal — these apply to every decision, in every project. When a task conflicts with a principle, say so before proceeding.
The table is the working summary. Read a file when a decision turns on that principle.
| Principle | Rule |
|---|---|
| SOLID | Five OO design rules; the umbrella for SRP, Open/Closed, and Dependency Inversion. |
| DRY | One authoritative home per piece of knowledge — but duplication beats a wrong abstraction. |
| KISS | The simplest thing that fully solves the stated problem. |
| YAGNI | Build what is asked for now; no speculative features. |
| SRP | One reason to change per unit. |
| Open/Closed | Add behaviour by adding code, not editing working code. |
| Dependency Inversion | Depend on abstractions; inject dependencies; wire at the edge. |
| Composition | Assemble small parts; inheritance only for true "is-a". |
| Separation of Concerns | Layer the system; dependencies point inward. |
| Fail Fast | Surface problems early and loudly; never swallow errors. |
| Measure First | No optimisation without a number, before and after. |
| Least Privilege | Minimum access, minimum scope, minimum lifetime. Default deny. |
Resolving conflicts
These principles pull against each other. Precedence when they clash:
- Least Privilege and Fail Fast — correctness and security are not traded away.
- YAGNI and KISS — do not build the abstraction yet.
- DRY, Open/Closed, and the rest — apply once the pattern is proven, typically at the third occurrence.
In short: keep it safe, keep it small, and generalise only when reality forces you to.