๐ข๐ป๐ถ๐ผ๐ป ๐ฎ๐ฟ๐ฐ๐ต๐ถ๐๐ฒ๐ฐ๐๐๐ฟ๐ฒ vs. ๐๐น๐ฒ๐ฎ๐ป ๐ฎ๐ฟ๐ฐ๐ต๐ถ๐๐ฒ๐ฐ๐๐๐ฟ๐ฒ - is there a difference?
Both architectures have a similar visual representation using concentric circles.
The Onion architecture has:
- Domain entities
- Repository interfaces
- Service interfaces
- Infrastructure, UI, Tests
The Clean architecture has:
- Entities
- Use cases
- Controllers, Gateways, Presenters
- Web, DB, UI, External interfaces
If you only look at this, you might think there's a significant difference.
However, they're more alike than it seems.
The Onion architecture and the Clean architecture revolve around the same idea - a core Domain containing entities.
You have the application services or use cases one layer above the domain.
The direction of the coupling is towards the center in both architectures.
Inner layers define interfaces.
Out layers implement interfaces.
Sounds familiar?
Another name for this is dependency inversion.
The conclusion I came to is that these architectures are interchangeable.
Any differences you see quickly fade when it's time to implement this architecture in a project.
And especially in the .NET community, I'm yet to see implementations of these architectures that are structurally different.
I use the Clean architecture.
By extension, I also use the Onion architecture.
And I find one of the names "cleaner" (pun intended).
If you liked this, consider joining The .NET Weekly - my newsletter with 29,000+ engineers.
Join us here โ milanjovanovic.tech
Did you consider these architectures to be different?
Both architectures have a similar visual representation using concentric circles.
The Onion architecture has:
- Domain entities
- Repository interfaces
- Service interfaces
- Infrastructure, UI, Tests
The Clean architecture has:
- Entities
- Use cases
- Controllers, Gateways, Presenters
- Web, DB, UI, External interfaces
If you only look at this, you might think there's a significant difference.
However, they're more alike than it seems.
The Onion architecture and the Clean architecture revolve around the same idea - a core Domain containing entities.
You have the application services or use cases one layer above the domain.
The direction of the coupling is towards the center in both architectures.
Inner layers define interfaces.
Out layers implement interfaces.
Sounds familiar?
Another name for this is dependency inversion.
The conclusion I came to is that these architectures are interchangeable.
Any differences you see quickly fade when it's time to implement this architecture in a project.
And especially in the .NET community, I'm yet to see implementations of these architectures that are structurally different.
I use the Clean architecture.
By extension, I also use the Onion architecture.
And I find one of the names "cleaner" (pun intended).
If you liked this, consider joining The .NET Weekly - my newsletter with 29,000+ engineers.
Join us here โ milanjovanovic.tech
Did you consider these architectures to be different?
On a related note, here's why I think Clean Architecture is great for complex projects ๐
milanjovanovic.tech
milanjovanovic.tech
Loading suggestions...