Your IoC Container Choice is Not a Feature of Your Application

I don't want to be a wet blanket, but someone's got to put a stop to the IoC love fest going on out there.  An Inversion of Control (IoC) container , for those of you were aren't yet familiar, allows you to retrieve instances of objects at runtime.  A relatively common solution to a common problem. In the .NET world there is no lack of choices of IoC containers:

(I won't go fully into IoC, but If you'd like more resource you can read Martin Fowler's article on the subject or post specific questions in the comments or contact me through.  Read on, there is value here in this post for you.)

Let me state clearly now, IoC containers are a means to an end and NOT a feature of your application. The goal is to have loosely coupled applications, IoC containers help get you there, but you can absolutely have a loosely coupled application without an IoC container (see the Gang of Four creational patterns).

Occasionally I'll hear some comment about IoC and how great a certain container is or how an application would be so much better if another, sexier, container was used.  Here are some recent tweets that illustrate:

  • Man i love #StructureMap, always finding new things i can do, and have fun doing them
  • really need to look at structuremap, but we''ve invested a lot into castle with our own facilities/resolvers/etc
  • Ninject is da bomb!
  • Switched from Windsor MicroKernel to Ninject in 10KLOC project in < 1 hour by creating a little proxy. Now to complete the conversion.
  • It is a talk on Castle Windsor so i guess Ninject will not do.
  • Can't imagine why somebody would use Ninject beside the fact that it's PURE AND UTTER AWESOME. Yeah! Ninject FTW.

Some of the statements above are probably innocuous, but some rub me slightly the wrong way.  Specifically the two comments above about switching from one container to another. There are probably times when the choice of one container over another makes sense, but I would bet that these scenarios are the exception and not the rule.

Choosing one container over another won't make your application a success, the architecture, or lack there of, will have far more of a say on your application than will your container choice. As yoda might say, "The container you choose does not a good app make".


Posted 03-29-2009 9:51 PM by Tim Barcz
Filed under: , , ,

[Advertisement]

Comments

scott wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-29-2009 11:43 PM

I don't at all disagree with the tone or message of your post, but there are valid reasons to switch containers.

For the same reasons we upgrade to new features in the .net fx or make architectural changes in our apps to make them more robust, or more succinct, or more intention-revealing, or more maintainable, or w/e, we may change a container to make it less xml-heavy for maintenance/upkeep reasons or take advantage of some new convention based config to make attributes go away and decouple a bit. Or maybe there's speed or size improvements to be had.

Just sayin it seems pretty knee-jerk to hate on container switchers.

progg.ru wrote Выбор IoC-контейнера не является особенной функцией твоего приложения
on 03-30-2009 3:42 AM

Thank you for submitting this cool story - Trackback from progg.ru

Mark Nijhof wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 4:12 AM

I agree with Scott on this, the main difference between the different containers is how they are being setup. A choice for me is how readable the configuration is for others in the project.  Also some are more sophisticated in some scenario's that you may not have needed at the start and you went for what you were convertible with and later realized it would help you in development, so why no switch container.

I agree with you about it not being a feature that you use in your advertisements :) but it _can_ give an _initial_ impression on how decoupled the code is.

Krzysztof Koźmic wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 7:18 AM

Two random thoughts:

Yes, switching to another container, because it's advertised as being more sexy is plain stupid. However there are much deeper differences between container than just registration/retrieval syntax. This is simple DI, and mature containers (StructureMap, Spring, Windsor) offer much more beyond simple DI. When you realize that, and want to switch to one of these containers to reap benefits of thsese additional features to simplify your architecture and/or make faster progress with your application, this is a valid reason.

It all depends on the context though. When you have invested in a good, mature container, adding features/modifications you need i's more often than not, just a matter of finding a right extension point and using it.

This rush towards lambda-driven containers remind me of similar movement in mocking frameworks space, where people started using MoQ when it was very new because it had such a cool name and used these new funky lambda magic, only to realize it lacks features, and to move back to old .NET 2.0 smelly Rhino.Mocks.

If something was good few months ago, is it worse now because it does not use latest super-duper kung-fu API/language?

Tim Barcz wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 9:20 AM

@Scott and Mark,

I agree with both of you.  There are valid reasons to switching and both of you touched on some of the them, however I tried to stay away from these reasons as most everyone thinks their reason(s) are valid.

This is where @Krzysztof's point hits home.  I think many of the times the reasons are not valid and because some desire to use "latest super-duper kung-fu API/language".

Nate Kohari wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 9:29 AM

You're absolutely right that a choice of container is only a matter of personal preference, and has very little to do with your application. In fact, that's really the only reason Ninject even exists -- I didn't like the existing offerings, so I wrote my own. :) If someone prefers another container, then by all means they should use it, and I don't think anyone should waste the time to switch between containers without a very specific reason in mind.

new ThoughtStream("Derick Bailey"); wrote Your [type of framework / tool] Choice is Not a Feature of Your Application
on 03-30-2009 9:56 AM

Tim Barcz posted a great article on how the specific choice of an IoC container doesn’t really mean much

Krzysztof Koźmic wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 10:32 AM

@Nate

What exactly were you dissatisfied with? Why not join an existing project and improve the existing tool, instead of starting from scratch?

Fernando Zamora wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 10:52 AM

It would be helpful if we could define an IoC container to some core functionality ; GetInstance, CreateInstance, BuildUp.  The first two are easy to create adapters are easy to create adapters for. The third one, because it relies on attribute decorations, is difficult to create an adapter for.  Meaning that it requires code modification and recompilation.  It seems that as a community we need to define some standards for IoC containers.  Then it wouldn't matter which one you use.  You could easily swap one out for another.

Additionally containers are beginning to get more feature rich with features that apply Aspect-Oriented Programming concepts.  Making it more difficult to swap one container for another.

Are we making IoC containers more complex than they need to be?

Tim Barcz wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 10:52 AM

@XStoff (Kryzsztof),

Too late now :-) but still a great question.  I questioned a guy on twitter who was saying that he was going to build his own bug tracking software because all of the ones out there were deficient.  Given how many bug databases are out there, I was surprised to know that absolutely none of them were even close enough to what he wanted that he could add in the feature.  It was "cheaper" in his mind to create the whole thing from scratch as a single developer rather than use Bugzilla, Trac, or other mature bug tracker....

Chris Canal wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 10:54 AM

I completely agree with Krzysztof Koźmic.

My main reason for sticking with Castle is more about the facilities that are supplied than the container.  IoC containers are dime a dozen, but it's the "extras" that make me stick.

However, I am no more loyal to Castle than I am to Nike, and trying out different IoC containers and the fearures they bring the to table is something I as a developer should keep on top of.  As transparent as an IoC container is, the easier it is to get what you want from it the better, Castle delivers this but as soon as something else delivers better value cheaper, I will switch :)

Tim Barcz wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 11:04 AM

@Chris

I agree with keeping up with what's going on out there, which is why in some smaller apps I've been using/trying out StructureMap and have an interest in trying out Ninject.  

You used an interesting word "cheaper".  Explain, cheaper in terms of runtime perf, implementation of new features, training other devs how to use, other?

DotNetShoutout wrote Your IoC Container Choice is Not a Feature of Your Application - Tim Barcz - Devlicio.us
on 03-30-2009 3:22 PM

Thank you for submitting this cool story - Trackback from DotNetShoutout

Matt Hinze wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-30-2009 8:55 PM

I agree that an IOC tool isn't a feature, like a nail gun is not a feature of a house.

But I disagree that IOC tools are commodities and picking one over the other won't matter that much.  "Choosing one container over another won't make your application a success" - true, but choosing the wrong one can make your application a failure.

Some of these tools are hobbyist products. Now that is not a dig on a specific tool, although it will likely be interpreted that way.  But the facts are that some of the tools you list have been in production, for years and years, in big huge projects and some haven't.

Things happen.  Bugs surface.  Developers spend weeks debugging and patching trunks.  Hobbyists end support and their products are obsoleted earlier than is optimal.  There is a public example of this in recent memory.

The point is: it DOES matter which container you choose.

Tim Barcz wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-01-2009 9:52 AM

@All

I think what Matt is referring to is that some of the containers mentioned above are more sea worthy than others.  Some of these containers have been around for years and are part of large enterprise applications, while some, the "hobbyist" products, are in their infancy and have yet to really be tested under heavy load or in a large application.

Matt's point can be more broadly applied to any tool out there, regardless of origin (OSS, Microsoft, other).  Typically I would not use something in production which hasn't been demonstrated to work well in other large applications.

Kazi Manzur Rashid's Blog wrote ASP.NET MVC Best Practices (Part 1)
on 04-01-2009 11:44 AM

In this post, I will share some of the best practices/guideline in developing ASP.NET MVC applications

Zhao wei Liang wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 12-31-2009 12:14 AM

It is better that we have a wrapper like JQuery, IoCQuery perhaps?

buy battery wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 01-16-2012 4:39 AM

Thanks for sharing! The reason for your blog is always to document your life and give your personal thoughts

cheap backlinks wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 01-17-2013 10:05 PM

3Bcs0h Im thankful for the blog article. Fantastic.

loss weight pills wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 02-01-2013 2:28 AM

Lm89uF Awesome blog article.Really looking forward to read more. Will read on...

Pharmf682 wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 02-04-2013 6:37 AM

Hello! akkdbck interesting akkdbck site! I'm really like it! Very, very akkdbck good!

buy stendra online wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 02-13-2013 9:02 PM

CjJYXw Thanks-a-mundo for the blog.Really looking forward to read more. Want more.

Clomiphene 50 mg wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 02-27-2013 10:23 PM

ddgJy3 Major thanks for the blog article.Really looking forward to read more.

social bookmarking service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-23-2013 1:47 PM

ZdTXcx Really informative blog. Much obliged.

comedy channel wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-06-2013 5:33 PM

Thanks so much for the blog post.Really looking forward to read more. Awesome.

social bookmarking service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-19-2013 5:45 AM

wYC7Xb Say, you got a nice post.Really looking forward to read more. Much obliged.

Social bookmarks wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-28-2013 2:29 AM

sPqM38 Great, thanks for sharing this article.Really looking forward to read more. Keep writing.

best compact digital cameras wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 05-14-2013 1:07 PM

mgLs4q Fantastic blog.Really looking forward to read more. Keep writing.

seo service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 05-29-2013 7:12 AM

k2aqIg This is one awesome article.Really looking forward to read more.

social bookmarking service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 06-06-2013 5:42 PM

yVOEAk Really appreciate you sharing this blog.Thanks Again. Will read on...

best social bookmarks wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 06-19-2013 6:28 PM

74yUoa A big thank you for your blog.Thanks Again. Much obliged.

great service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 07-04-2013 11:07 AM

sq1kl7 I think this is a real great article post. Fantastic.

best news wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 08-02-2013 10:24 AM

Thanks-a-mundo for the blog article. Really Cool.

greatest news wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 08-02-2013 2:53 PM

sEtRWd I think this is a real great article post.Much thanks again. Much obliged.

best news of them all wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 08-04-2013 10:40 PM

qiykt6 wow, awesome post.Thanks Again.

great link buildng wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 08-19-2013 6:59 AM

I6FWM2 Thanks for the blog post.Really looking forward to read more. Fantastic.

awesome links for you wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 08-19-2013 7:19 PM

Rc9sL0 I loved your post. Really Great.

great seo service wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 09-04-2013 3:09 AM

zEBDI1 I value the blog article.Really looking forward to read more. Really Cool.

online business wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 09-11-2013 5:12 PM

BXV3BH I really like and appreciate your article.Really thank you! Keep writing.

cheap link building wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 09-24-2013 8:54 AM

a2g7nq Enjoyed every bit of your blog. Cool.

best linkbuilding wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 09-30-2013 9:12 PM

Od7URV I am so grateful for your article. Really Cool.

check out these guys! wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 10-16-2013 2:37 AM

rXVOs8 Thank you ever so for you blog.Really thank you! Great.

top seo guys wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 11-01-2013 4:26 PM

rna1iO Very good blog post.Really thank you! Will read on...

click here wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 11-19-2013 3:54 AM

IIkV6w This is one awesome article. Really Cool.

awesome site wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 11-21-2013 2:56 AM

CuCazL Really informative post. Fantastic.

stunning seo guys wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 01-19-2014 4:20 PM

ksM3rJ Major thanks for the blog.Thanks Again. Great.

check it out wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 01-20-2014 7:45 AM

i9RJqz Very neat blog.Thanks Again. Much obliged.

awesome things! wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 02-28-2014 8:46 AM

KcWFlD I appreciate you sharing this blog article.Really thank you!

check this out now wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-25-2014 9:32 AM

RsJAkc Very neat post.Thanks Again. Really Cool.

seo for cheap wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 03-26-2014 12:56 AM

cEmNfW Very informative article.Really looking forward to read more. Fantastic.

best prices wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-01-2014 12:55 PM

lNeWr2 Major thankies for the blog.Really looking forward to read more. Keep writing.

check this out now wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-06-2014 3:22 AM

IeK1Rk Im grateful for the article post. Great.

awesome things! wrote re: Your IoC Container Choice is Not a Feature of Your Application
on 04-20-2014 7:51 PM

TsyZ4x Very informative article post.Much thanks again. Awesome.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)