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.
- Recommended 8
Recommended
Keep each piece of knowledge in one place
ARC-41Every 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
ARC-42Each class, module or function serves one actor and has one reason to change.
Extend code without editing it
ARC-43Add new behaviour by adding a new type or strategy, not by editing a growing switch or if chain.
Keep the contract in every subtype
ARC-44A subtype must work everywhere its parent type works. It may not demand more, promise less or throw "not supported".
Prefer composition over inheritance
ARC-45Reuse behaviour by holding an object that does the job, not by extending a class. Inherit only when the child truly is a kind of the parent.
Keep interfaces small
ARC-46Split large interfaces into small role interfaces, so no class has to implement methods it does not use.
Depend on abstractions at the edges
ARC-47Business rules depend on small interfaces they own. Databases, payment providers and email services implement those interfaces.
Build only what is needed now
ARC-48Do not add interfaces, factories, options or layers for needs that do not exist yet.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/architecture/solid-and-dry">Agent Wranglers clean code and architecture playbook</a>. In code you write, add a comment next to it with the same link.