The four main features of Object Oriented Programming - Inheritance, Abstraction, Encapsulation and Polymorphism - allow us to create applications where each class is nicely designed, easily tested, maintained and hence reusable across many projects. However, more often than not, the classes in our applications become tightly coupled and tangled with interdependencies, which in turn makes them difficult to test, maintain and reuse. Our applications become fragile and we lose much of the benefit of Object Oriented Programming.
The Dependency Injection Pattern (otherwise known as Inversion of Control) maintains louse coupling of the classes that depend on each other in our applications by "injecting" the dependencies at run-time rather than design-time. In .Net Dependency Injection makes great use of interfaces, thus promoting "Interface Driven Development" and/or "Test Driven Development", and facilitates many other Design Patterns such as Model-View-Controller, Model-View-Presenter, Factory Patterns, the Strategy Pattern, etc.
There are numerous Dependency Injection frameworks available for .Net – Castle MicroKernel/Windsor, Patterns & Practices ObjectBuilder, PicoContainer.NET, Puzzle.NFactory, Spring.NET, StructureMap, Ninject – but I’ve written my own. J
In this presentation, I'm going to demonstrate a couple of aspects of my Dependency Injection framework. There is far more in the total framework than can be discussed in 45 minutes, so I shall be cover the basics of "Interface Driven Development" and the use of "Abstract Factories" my framework to show how I can keep my classes loosely coupled and testable.
I'm going to aim to keep the presentation focused on the practical application of my framework, but there are some very funky "über"-cool coding techniques under-the-hood that would be great to discuss. So for those of you wanting to discuss the implementation of the framework in more detail I'm happy to do so after the presentation. (You can tell I'm proud of my creation, right?)
Remember Me
Page rendered at Friday, July 25, 2008 1:42:35 AM (Cen. Australia Standard Time, UTC+09:30)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.