View
338
Download
3
Category
Tags:
Preview:
Citation preview
@IamVMac
ABOUT ME• Coder by Profession | Gamer by Heart |
Polyglot & Pragmatic Programmer
• Microsoft MVP – Xbox | Intel Software Innovator | Developer @ DELL
• @iAmVMac
• http://iamGa.Me
• http://about.me/mscvidyasagar
@IamVMac
Layered Architecture
Partitions the concerns of the application into stacked groups (layers).
@IamVMac
Traditional 3-layer Architecture
Infrastructure / DAL
Core / BLL
UI
DB
Uti
liti
es
/ C
om
mon
/ S
hare
d
nHibernate /
LINQ to SQL
ASP.NET
Log4Net
AutoMapper
StructureMap
@IamVMac
• Very easy for developers over time to put more and more business logic in the UI layer
• Counter-productive to build your application on top of a specific technology that is sure to change over time
• Logic is easily scattered all over, locating code becomes a major effort.• Developers over time struggle to determine where code should go… DAL? BLL?
Utilities?• Business logic has many tentacles extending from it (directly and indirectly)• Library explosion: Makes it easy take a dependency without putting much thought
into it, and now it’s littered all over the code base
Problems with Traditional Architecture
@IamVMac
The Onion Architecture to rescue• Quoted by Jeffrey Palermo in 2008.• relies heavily on the Dependency Inversion principle.• The database is not the center. It is external.
@IamVMac
Dep
en
den
cy
Reso
luti
on
User I
nterface
Infrastructure
ProductRepository<<class>>
Application Core
Application Services
Domain Services
Domain Model
IProductRepository
DB
IUserSession
HttpUserSession<<class>>
ProductsControllerBrowser hits: /Products/List
@IamVMac
• Everything unique to the business: Domain model, validation rules, business workflows
• Defines all technical implementation (non-business) needs as interfaces
• CANNOT reference any external libraries• NO technology specific code
Core
• Provide implementations for Core interfaces• Call web services, access a database• CAN reference external libraries to provide implementations• ONLY technology specific code (non-business) belongs in
infrastructure
Infrastructure
• Very thin layer, has no logic of its own• Wires up Core interfaces to Infrastructure implementations. • Runs startup/configuration logic
Dependency Resolution
Recommended