Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laying it out: Onion Architecture

Laying it out: Onion Architecture

Fanie Reynders

February 16, 2013
Tweet

More Decks by Fanie Reynders

Other Decks in Programming

Transcript

  1. The centre of your application is not the database, it's

    the use cases of your application. Fanie Reynders @FanieReynders “ ”
  2. Traditional Layered Architecture Infrastructure / DAL Core / BLL UI

    DB Utilities / Common / Shared nHibernate / LINQ to SQL ASP.NET Log4Net AutoMapper StructureMap
  3. 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
  4. Inverted Dependencies Infrastructure / DAL Core / BLL UI DB

    Utilities / Common / Shared nHibernate / LINQ to SQL ASP.NET Log4Net AutoMapper StructureMap
  5. Onion Architecture Infrastructure (DAL) Core (BLL) UI DB Dependency Resolution

    (Utilities) nHibernate / LINQ to SQL ASP.NET Log4Net StructureMap AutoMapper
  6. 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
  7. 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