Props go to Rob Conery and all of the folks at TekPub. I think what they are doing with learning videos is a great effort, and will go a long way in spreading the word and know-how to the developer community. Most of the videos require a subscription, with the occasional free series. The first video in the Concepts series covers Dependency Injection and Inversion of Control.
The video introduces Ninject, “…the illegitimate brainchild of Nate Kohari.” In all seriousness, it’s a great framework for Dependency Injection. The first part of the video walks through a simple example, and then refactors it for Dependency Injection by extracting interfaces. This is great, but the real trick is the Inversion of Control. Using Ninject, a constructor can be decorated with an [Inject] attribute. This allows Ninject to know where to use its magic.
The DI framework uses a concept of Kernels, which are instantiated with Modules, and Modules are where dependencies are defined. In the example, a new class is created that inherits from NinjectModule. The Load method is overridden, and some neat syntax is used to describe relationships and injections.
I won’t ruin the video, so go check it out!
Concepts: #1 Dependency Injection and Inversion of Control