Share
Embed
Laying it out: Onion Architecture
Fanie Reynders
February 16, 2013
Transcript
13 slides
-
The centre of your application is not the database, it's
the use cases of your application. Fanie Reynders @FanieReynders “ ” -
Traditional Layered Architecture Infrastructure / DAL Core / BLL UI
DB Utilities / Common / Shared nHibernate / LINQ to SQL ASP.NET Log4Net AutoMapper StructureMap -
Problems with Traditional Architecture Very easy for developers to put
increasing business logic in the UI layer Application is built on top of specific technology that is sure to change over time – counter productive Logic is scattered all over – difficult to locate & track Where should the code go? BLL? DAL? Utilities? Business Logic with extending tentacles Library Explosion – Easy to take a dependency -
Inverted Dependencies Infrastructure / DAL Core / BLL UI DB
Utilities / Common / Shared nHibernate / LINQ to SQL ASP.NET Log4Net AutoMapper StructureMap -
Onion Architecture Infrastructure (DAL) Core (BLL) UI DB Dependency Resolution
(Utilities) nHibernate / LINQ to SQL ASP.NET Log4Net StructureMap AutoMapper -
Benefits of Onion Architecture True loosely coupled Limit re-write over
time – Business Logic self contained Very portable Business Logic has no dependencies Architecture more sustainable over time Infrastructure free to use any data access or external service to accomplish task UI & Data Access smaller – deal directly with technology-related code Compiler enforces dependency boundaries -
Traditional Layered Architecture • Unique to business: Domain model, validation,
business workflows • Defines contracts • CANNOT reference external libraries • NO technology specific code Core • Provide implementations for Core interfaces • Call web services, access database • CAN reference external libraries • ONLY contains technology specific code (non-business) Infrastructure • Wires up Core interfaces with Infrastructure implementations • Runs start-up / configuration / binding logic Dependency Resolution