July 2011 Meeting

Onion Architecture With ASP.NET MVC

Onion Architecture is a specific type of solution architecture that was first introduced to me by Jeffrey Palermo. Over the years nearly every project Ive worked on used a traditional layered architecture under the guise of loose coupling. Yet in every single case as the project progressed we realized more and more that our layer abstractions werent actually abstractions at all. Sure we may be coupling ourselves between layers using interfaces — but a giant DAL interface with 30 members is almost certainly going to be tied to a specific implementation, despite our best intentions.

Layering also opens to the door to too much developer decision making, causing a great deal of inconsistency. When you need to add a new feature to the UI, the developer is completely free to put the code for his feature in any layer he chooses — from the presentation layer on down, or perhaps in the dreaded “Shared/common/utility” project.

Onion architecture helps us fight this by enforcing true loose coupling. As you will see throughout the talk, our UI layer has no reference to any infrastructure/DAL, just the Core business logic. Even the business logic (Core) has no access to any infrastructure concerns. Rather than build on top of the database, it externalizes it. It defines what it needs using its own interfaces, and they are implemented as far outward as possible in Infrastructure. We then bind them together using an IoC container to bring the application to life.


Matt Hidinger is a .NET developer and enthusiast. He is currently doing .NET consulting at Triton-Tek focusing on ASP.NET MVC, Silverlight, and Windows Phone 7.

When: 2011-07-13 18:00:00

Where: Redpoint, 233 South Wacker Dr, Suite 750, Chicago (map)

comments powered by Disqus