Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onion Architecture

Tags:

I am setting up a project structure for an upcoming internal application trialling the Onion Architecture proposed by Palermo (http://jeffreypalermo.com/blog/the-onion-architecture-part-3/).

I have followed his guidelines, however I need some verification on the structure of the project so far.

Before the diagrams, the questions:

  1. I think the References are all correct (set up as per the diagram where an arrow means 'has a reference to') but some verification would be good.

  2. What should I put in my dependency resolution layer? Is this where Helpers go? This has a reference to all other projects?

  3. How do the web services & UI, communicate with the DAL? (Through the core? How?)

  4. What should go where? [Broad question I know...]

The simplified conceptual diagram is as follows (Folders represent namespaces):

enter image description hereenter image description here

like image 531
Darbio Avatar asked Jul 21 '11 05:07

Darbio


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.

Why onion is used in architecture?

Advantages of Onion ArchitectureIt provides better maintainability as all the codes depend on layers or the center. It provides better testability as the unit test can be created for separate layers without an effect of other modules of the application.

What is onion architecture in .NET core?

The Onion architecture is a form of layered architecture and we can visualize these layers as concentric circles. Hence the name Onion architecture. The Onion architecture was first introduced by Jeffrey Palermo, to overcome the issues of the traditional N-layered architecture approach.

What is onion clean architecture?

Key tenets of Onion Architecture:The application is built around an independent object model. Inner layers define interfaces. Outer layers implement interfaces. Direction of coupling is toward the center. All application core code can be compiled and run separate from infrastructure.


1 Answers

I think the References are all correct (set up as per the diagram where an arrow means 'has a reference to') but some verification would be good.

1 It looks OK but I am not sure it's a good idea to insert dependency resolution into the diagram.

What should I put in my dependency resolution layer? Is this where Helpers go? This has a reference to all other projects?

2 I believe dependency injection stuff would be here.

How do the web services & UI, communicate with the DAL? (Through the core? How?)

3 It is core according to Palermo's diagram. In core, you will have repositories talking to DAL and domain models, and services (not web services) dealing with repositories and domain models. And UI/web services will mainly talk to services.

What should go where? [Broad question I know...]

4 Again, I think the answer is in Palermo's diagram. But in my opinion, organizing projects can be different and trivial when there is full understanding of the architecture.

Onion architecture became obvious to me once I understood DDD and necessary design patterns such as MVC, Dependency injection, Repository/Service, ORM.

like image 91
Tae-Sung Shin Avatar answered Oct 03 '22 18:10

Tae-Sung Shin