Question

Note: BLL = Business Logic Layer (can also mean your domain)

I'm trying to understand the onion architecture. It seems to me that it's actually the same thing as the layered architecture, only with the dependency inversion principle (DIP) applied. For example, this is the typical layered architecture (arrows represent dependencies):

UI > BLL > DAL

Note: That's simplified, and should not imply that DIP can't/isn't used with it. DIP simply means that we should depend on abstractions.

This is the typical onion flow (also simplified):

UI > BLL < DAL

Notice the last arrow is reversed. The BLL has the abstractions, so they're at the center of the onion, and the other layers reference it. Onion article: http://jeffreypalermo.com/blog/the-onion-architecture-part-1/

Since I'm used to the layered architecture, I wanted to see what the flow would look like if I combined that with DIP. Here it is:

UI > [interface] < BLL > [interface] < DAL

Excellent diagram of DIP, which mirrors this. https://en.wikipedia.org/wiki/Dependency_inversion_principle

Here is an article explaining the difference between layered and onion. It made me have the questions I presented above. http://blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same/

So my question is, what is the difference between the onion architecture, and the layered architecture with DIP? Is there one?

My question has been flagged as a possible duplicate of this one: Onion architecture vs 3 layered architecture Mine is different because I want to know if there really is such a thing as the onion architecture. If you claim the onion architecture is layered + DIP, then does the onion really exist? Or would that mean that the onion really is just a version of layered, like layered with bad practices?

Was it helpful?

Solution

It seems to me that most 'new' things in software architecture are old ideas refurbished and combined with new technologies or other ideas. Often these are incremental.

In this case, the change that I think matters is the database is no longer the center of the design. This is not an minor change; it's pretty fundamental. So is the "onion architecture" really just the layered architecture plus DIP? Maybe. But steel is roughly iron plus carbon. Does that mean steel isn't a real thing?

Words are labels. This one stuck. I'm not sure what else there is to say about it.

Licensed under: CC-BY-SA with attribution
scroll top