180 likes | 276 Views
Using an Inversion of Control Container in a real world application. Certified Mort. Mike Hadlow mikehadlow@yahoo.com http://mikehadlow.blogspot.com. What’s am I going to talk about?. Architecture with IoC IoC and the MVC Framework Entities and Services Generic Repository Facilities
E N D
Using an Inversion of Control Container in a real world application Certified Mort Mike Hadlow mikehadlow@yahoo.com http://mikehadlow.blogspot.com
What’s am I going to talk about? • Architecture with IoC • IoC and the MVC Framework • Entities and Services • Generic Repository • Facilities • Multitenancy
Suteki Shop • A simple eCommerce application • Built for Jump the Gun in Brighton • Open Source
Dependency Injection • Do not directly instantiate concrete instances • Inject dependencies as constructor arguments • Let the IoC container supply dependencies
Onion Architecture UserInterface Tests
IoC and the MVC Framework • MvcContrib supplies a WindsorControllerFactory
Entities and Services • Entities are not supplied by the IoC container • Entities have no dependencies on any other part of the application • Entities supply the schema and rules of the business • Services are supplied by the IoC container • Services tie Entities to infrastructure
Generic Repository • Supplies a generic abstraction over the underlying data access technology • Works nicely with ORMs
Mixins • The first rule of Mixins: we have no Mixins
Moving on from Repository • We can leverage the generic repository to write other generic services • IOrderable • Scafolding
Facilities • Facilities allow us to package and reuse container configuration • Many off the shelf facilities • Logging • WCF integration • Nhibernate integration
WCF Facility • Allows us to publish components as WCF services • Can also host WCF proxies as services
Multitenancy • How do we provide client customisations? • Single/multiple code base? • Single/multiple application instance? • Single/multiple database?
Where are we now? • Write your application as many small components • Use an IoC container to host components • Onion architecture • Use a generic repository • Use facilities • Customise deployment/runtime with the container