Jan Veen

Clean Architecture Principles


SRP: Single Responsibility Principle

A module should have one and only one reason to change.

A module should be responsible to one, and only one, user or stakeholder.

A module should be responsible to one, and only one, actor.

OCP: Open-Close-Principle

A software artifact should be open for extension but closed for modification.

LSP: Liskov’s Substitution Principle

What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T.1

ISP: Interface Segregation Principle

Interfaces should be separated from implementation.

DIP: Dependency Inversion Principle

A module should not refer to or derive from volatile, concrete code.

Component Principles

REP: Reuse/Release Equivalence Principle

Code that is reused together, should be released together as one module.

CCP: Common Closure Principle

Group code that changes for the same reason at the same time into the same component.

CRP: Common Reuse Principle

Don’t force users of a component to depend on things they don’t need. Group usually commonly reused code into the same component.

Component Coupling

ADP: Acyclic Dependency Principle

Allow no cycle in the component dependency graph.

SDP: Stable Dependency Principle

Depend only on components that are more stable than you.

Instability $I = (outgoing-dependencies) / (outgoing-dependencies + incoming-dependencies)$

I = 0 indicates maximum stability

I = 1 indicates minimal stability

SAP: Stable Abstraction Principle

A compnent should be as abstract as it is stable

Abstractness $A = #abstract-classes / #classes-total$

A = 0 indicates a completely concrete component

A = 1 indicates a completely abstract component

Main Sequence

The distance $D = |A + I - 1|$ should be minimised.