SOLID and DRY
Keep each piece of knowledge in one place and give each module one reason to change. Extend code by adding to it, not editing it.
- Required 4
- Recommended 3
Required
Keep each piece of knowledge in one place
RequiredEvery rule, value and decision lives in one place in the code. Repeated text is fine. Repeated knowledge is not.
Give each module one reason to change
RequiredEach class, module or function serves one actor and has one reason to change.
Keep the contract in every subtype
RequiredA subtype must work everywhere its parent type works. It may not demand more, promise less or throw "not supported".
Build only what is needed now
RequiredDo not add interfaces, factories, options or layers for needs that do not exist yet.
Recommended
Extend code without editing it
RecommendedAdd new behaviour by adding a new type or strategy, not by editing a growing switch or if chain.
Keep interfaces small
RecommendedSplit large interfaces into small role interfaces, so no class has to implement methods it does not use.
Depend on abstractions at the edges
RecommendedBusiness rules depend on small interfaces they own. Databases, payment providers and email services implement those interfaces.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/solid-and-dry.