Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean Architecture vs Onion Architecture

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

like image 939
user3373870 Avatar asked May 05 '14 19:05

user3373870


People also ask

What is onion architecture?

Onion architecture consists of several concentric layers interacting with each other towards the core, which is the domain. The architecture does not depend on the data layer, as in a traditional three-tier architecture; it depends on real domain models.

What is meant by clean architecture?

Clean architecture is a software design philosophy that separates the elements of a design into ring levels. An important goal of clean architecture is to provide developers with a way to organize code in such a way that it encapsulates the business logic but keeps it separate from the delivery mechanism.

What are the four layers of clean architecture?

Clean architecture vs. The logical layers of this style are as follows: Presentation layer ( accounts for the presentation to the user) Business logic layer (contains the business rules) Data access layer (processes the communication with the database)


3 Answers

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.

like image 140
George Howarth Avatar answered Sep 30 '22 10:09

George Howarth


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.

like image 36
xurxodev Avatar answered Sep 30 '22 12:09

xurxodev


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.

like image 2
user1506878 Avatar answered Sep 30 '22 10:09

user1506878