Clean Architecture
Clean Architecture
Augustinas Nomicas
.NET Developer
What is good software architecture?
● Easily testable
● Independent from database
● Independent from frameworks
● Always ready to deploy
● High isolation of modules
Clean architecture is not always
right for small projects
So...
???
The center of your application is not the
database. Nor is it one or more of the
frameworks you may be using. The center
of your application is the use cases of your
application - Uncle Bob
Insurance company example
Wikipedia:
a use case is a list of actions or event steps typically defining the interactions
between a role (known in the Unified Modeling Language as an actor) and a
system to achieve a goal.
These use cases orchestrate the flow of data to and from the entities, and
direct those entities to use their Critical Business Rules to achieve the goals of
the use case.
Two cases of business rules
References
AddCar CarSqlDB AddCar CarSqlDB
References
Implements
ICarStore
Entities
○ Easy testable
Use Cases
● No, the circles are schematic. You may find that you need more than
just these four.
● Data that can cross boundaries are only simple data structures
● Application.Startup method
Screaming architecture
● Same functionality put under same folders and easy to find (high
cohesion)
What about .NET
Framework?
What about MVC?
○ Intention was to use for small UI object (button, text input, circle)
○ We can test our Entities and Use-cases (business logic) without database and UI
architecture
ASP.NET Examples
ASP.NET project template
https://marketplace.visualstudio.com/items?itemName=
GregTrevellick.CleanArchitecture
Northwind Traders in ASP .NET Core
https://github.com/JasonGT/NorthwindTraders
● UI (Presentation) is a Detail
More By Robert C. Martin (Uncle Bob)
Ačiū!