Saturday, January 23, 2010

Ayende on Dependency Injection

Here is another post from Ayende, this time on rejecting Dependency Injection inversion. It is worth reading and highly recommended for those, who don’t like the very idea of IoC usage. For example, Alex Ilyin is from that camp. Recently we had quite interesting conversation on this topic in comments to this post.


  1. The original Uncle Bob's article is really based on quite simplified example, and thus conclusions made there are pretty far from reality.

    Concerning Alex Ilyin's response: I didn't state it there (although I did this @ office), so... I actually think IoC we're going to use there must be based on what we already have: DomainConfiguration.Types allows us to get all the LINQ query preprocessors gathered automatically (by convention over configuration way); if user prefers another way of IoC here, he must simply declare a preprocessor resolving its descendants using its favorite IoC container.

    More details on this are described in issue 557 and issue 573.

    P.S. I like IoC in general. But I think it's not a good idea to so tightly bind it to DO4 framework, i.e. we must not require our users to use (and configure!) some IoC framework. IoC must be supported, but this must be fully optional.

    The example you published wasn't implying this, but this is very important: we precisely know that DO4 users actually dislike the fact that new DO4 is bound to a set of external components much harder than before - even although currently we're bound just to CommonServiceLocator and PostSharp. So pushing them to use _any_ 3rd-party IoC container in pretty basic cases isn't good at all. On the other hand, supporting the same (= known) convention over configuration pattern here is good, and moreover, it does not limit them in usage of IoC.

  2. Hello, thanks for the link it is interesting, but I am not "on that camp". Moreover, I used to implemented IoC container myself and I still use it.
    About using IoC containers in DataObjects- I just like simplicity and I still think that solution I suggested is the simplest. :)