Clean Architecture vs Onion Architecture [closed]
Asked Answered
B

3

67

I have been reading up on the Onion Architecture and today I found out about Uncle Bob's Clean Architecture.

For the life of me I cannot see any differences between them, they look identical (other than the naming convention).

Is there any differences between the two architectural styles? If yes, can you explain it to me please?

Cheers

Boogie answered 5/5, 2014 at 19:6 Comment(0)
N
53

The term "Clean Architecture" is just the name of the article. The onion architecture is a specific application of the concepts explained in the article.

Navarrete answered 6/5, 2014 at 11:10 Comment(2)
in union architecture the model lies at center, then repository build upon it, and then service based on repositories, and then Presenters, APIs and testers on top of service layer. but on clean architecture, we have entity at core, use cases (which i'm not sure of) on top of that, then comes the controller, gateways, and presenter, and on top of that comes IO devices (Database, File system, Web, Devices, (not sure about "UI". maybe it's UI generator)), which by listening to uncle bob, they should attach as a plugin, build based on the application, not application build based on them.Lion
Clean Architecture is not just the name of the article. It has the whole book, where Robert Martin defined both a set of principles and a specific architecture. The clean architecture consists of four main layers: Enterprise Business Rules (Entities), Application Business Rules, Interface Adapters, Frameworks & Drivers. Onion Architecture also consists of four layers, but the dependencies between them and the structure are different. In Onion Architecture third layer has nothing to do with UI, in Clean Architecture, the third layer is responsible for Views, Presenters and ViewModels.Halfbeak
S
42

There are architectures like clean, hexagonal and onion with the same objectives and some differences in their implementation.

  1. Independent of Frameworks. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.
  2. Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element. Independent of UI. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.
  3. Independent of Database. You can swap out Oracle or SQL Server, for Mongo, BigTable, CouchDB, or something else. Your business rules are not bound to the database.
  4. Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.

In all architectures the goal is allows the most stable things are not dependent on less stable things will change more frequently.

The layer more important and more stable is domain.

This is the more important over these architectures, then if for onion the object for coordinate from user interface input to infrastructure, domain etc.. is a application service or if in clean architecture is a interactor are small details.

Stretto answered 16/2, 2016 at 14:23 Comment(1)
This comment is very good, but instead of answering the question "Are there any differences between the two architectural styles?" it describes similarities, which is the opposite of what was requested.Halfbeak
G
5

They do look alike and are used to achieve the same objectives which are mainly testability and separation of concerns, but you should notice that the Uncle Bob's Clean Architecture is more Use Case centric.

Gillead answered 17/9, 2014 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.