JC Grubbs
JC Grubbs

Reputation: 40311

What is the overhead cost associated with IoC containers like StructureMap?

After attending a recent Alt.NET group on IoC, I got to thinking about the tools available and how they might work. StructureMap in particular uses both attributes and bootstrapper concepts to map requests for IThing to ConcreteThing. Attributes automatically throw up flags for me that either reflection or IL injection is going on. Does anyone know exactly how this works (for StructureMap or other IoC tools) and what the associated overhead might be either at run-time or compile-time?

Upvotes: 3

Views: 1052

Answers (4)

Shay
Shay

Reputation:

I built a very lightweight and basic IOC, here:

http://blogs.microsoft.co.il/blogs/shay/archive/2008/09/30/building-custom-object-mapper.aspx

It's not an alternative to the libraries You mentioned but if all that You need is to resolve a type by giving its interface it might be a perfect solution.

I don't handle instantiation types (singleton, transient, thread, pool...), all object will be instantiated as singletons, you call it like:

IRepository _repository = ObjectFactory.BuildFactory<IRepository>();

Shay

Upvotes: 0

Darren
Darren

Reputation: 961

I use Windsor from the CastleProject and have found it immensely useful in reducing dependencies. I haven't noticed a performance issue yet but one thing I do find is that the configuration can get a bit cumbersome. To help in this regard I'm starting to look at Binsor, which is a DSL for Windsor written in boo.

Another thing to be aware of is that when navigating code you wont be able to go to the code that will be executing at runtime.

Upvotes: 1

aku
aku

Reputation: 123974

They major problem is that code becomes hard to understand. It might become pure magical if one overuse IoC. Another problem is performance. In most cases performance lost is not noticeable. But when you start creating most of your objects via IoC container, it can suddenly drop below ocean level.

Upvotes: 0

tgeros
tgeros

Reputation: 2940

I can't say much for other IoC toolkits but I use Spring.Net and have found that there is a one off initial performance penalty at startup. Once the container has been configured the application runs unaffected.

Upvotes: 1

Related Questions