I've spent the last week reading about Dependency Injection, and I think I may finally understand. First of all it is a type of Inverion of Control. Now .NET programmers see inversion of control all the time. Usually in the same place we encounter delegates: event handlers. The event handler actually controls the handling of the event and not the main program.

But Dependency Injection is a step beyond. DI inverts control of the program so that a dependent object is injected into its dependant object. So if I have an object [Foo] that depends on a [IBar] type, I can make a call to a container class (aptly named a Dependency Injection Container) and have it inject into the [Foo] object a concrete instance of a class that implements [IBar]. This relieves the actual dependency on the concrete instance of a class that implements [IBar]. To me, it's a bit like the Factory Pattern on steroids. I also read a bit about Service Locator, but that's about all my little brain can handle for now.

Enjoy!

~L

posted on Thursday, April 03, 2008 1:13 PM | Filed Under [ Dependency Injection ]

Comments

No comments posted yet.
Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 1 and 5 and type the answer here: