background preloader

Ioc

Facebook Twitter

Messaging

AspNetIntegration - autofac - Google Code - ASP.NET integration. Some IoC Container guidelines - Jimmy Bogard. So Derick Bailey asked me the other day a few weeks ago to describe how we use our IoC container. I wouldn’t call it “best practices”, though some of these tips came from the creator of our container of choice, StructureMap (Jeremy Miller). Although IoC containers are everywhere these days, you don’t see many instructions on where and how to use them. We’ve developed a consistent approach to using our favorite container of choice, StructureMap. The basic ideals behind our approach are: Hiding the framework If you look through one of our projects that use StructureMap, you’ll be hard pressed to find any usages of StructureMap. In fact, one recent project had exactly one file that used StructureMap. Just like any framework, littering your code with references and usages can make it nearly impossible to change to a different container.

Looking at StructureMap, hiding the framework means preferring the fluent configuration or the xml configuration. Minimize calls to the container. Code Insanity: Building a generic IoC wrapper. Ninject: Lightning-fast dependency injection for .NET. Windsor IoC Container in a Lunch Break.