I really like Ninject and Autofac even though I don't get to use them
enough as my clients tend to be more Microsoft-based and therefore use
Unity and Enterprise Library.
I can give you some positives on Unity since I use it daily, however.
Unity is particularly nice if you use Enterprise Library. There are
Enterprise Library Extensions that auto-register themselves with Unity
which makes working and injecting the various blocks really easy.
Therefore, if you use a lot of the blocks in Enterprise Library, you
will probably want to use Unity.
Unity has two ways to register components: 1) XML and 2) Fluent
Interface. I hate XML, but it is very handy at times. The fact that
Unity gives you the choice as well as the ability to use both at the
same time is really nice in those circumstances where you can benefit
from the flexibility of XML to make configuration changes.
Unity also does not require you to use attributes on your classes. You
can achieve pure POCO using the XML or Fluent Interface alone. The
Fluent Interface is much more verbose than I personally prefer, but
very powerful. Attributes are purely optional and there just for your
convenience if you don't require POCO.
If you are big into AOP, I really love the seamless support for
various interception techniques in Unity as well as the ease of
building custom interceptors. Therefore if you are big into pulling
those cross-cutting concerns from your code and into reusable
interceptors, Unity gives you a number of interception options that
make it a breeze. Again, you can go full POCO with XML and Fluent
Interface techniques or use attributes if you find them more
convenient.
The patterns & practices team outsources their support to a
professional support organization that monitors their forums actively
so you shouldn't have a problem getting support. I haven't gone in
there in awhile, but the last time I looked they did a good job of
answering all the questions in a timely manner. Examples of using
Unity are everywhere so you probably don't even need to use the
forums.
Although P&P can appear to move slow on adding new functionality in
Unity and their other projects, I will say that the projects don't
stay in a never-ending "beta" which can happen with some OSS projects.
Therefore, in reality they probably do ship production, stable code
just as often as a lot of other OSS projects. However, they usually
only ship a major release and maintenance release each year and you
will have to wait for the next year for anything else to happen.
Thankfully they are not a "product team" at Microsoft or you would
have to wait for the next version of Visual Studio :)
So hopefully that provides a bit more balance on the opinions of
Unity, but alas, opinions will vary and I think it is always best to
try them out yourself and form your own opinions.
That being said, I can't say enough good things about other containers
like Autofac and Ninject. I use them any chance I can get. In fact my
whole reason for stumbling in here was to check on the status of
Ninject 2 to incorporate it into a new project. I have yet to use
version 2 and am looking forward to it. Any timeframe on when it may
actually be released? Not a requirement for my use as it appears to be
very stable, more of a curiosity.
Thanks,
Dave
On Oct 23, 7:43 am, Miguel Madero <
m...@miguelmadero.com> wrote:
> I forgot to ask. I started working with Ninject because it was the only IoC
> available for Silverlight (after using Object Builder in CAB, then Unity and
> Castle Windsor). I have to say it was thrilled to get away from the XML
> configuration.
>
> Also, in a recent project that I worked with Unity, I wrote a lot of
> extension methods to create the bindings easily, making the methods less
> verbose.
>
>
>
>
>
> On Fri, Oct 23, 2009 at 10:40 PM, Miguel Madero <
m...@miguelmadero.com> wrote:
> > Interesting answers. I didn't think before on most of those points, it just
> > felt natural to like Ninject better, but wasn't sure exactly why, but I've
> > to agree with every reason mentioned, specially that the names make a lot of
> > sense.
>
> > A couple of times I have had to through the internals and I found the Unit
> > Tests really useful to understand and as a great source of documentation,
> > while doing some low level stuff with Unity/Object Build is way harder even
> > with documentation.
>
> > Also debugging binding issues with the exception messages provided by Unity
> > is a pain: On Unity I’ve had some really cryptic error like
>
> > Resolution of the dependency failed, type = "MyClass", …. Could not load
> > type 'MyClass' from assembly '…’
>
> > MyClass isn’t even the dependency, is the type that I try to directly
> > resolve from the container, the class is in the specified assembly, so the
> > error message is obviously wrong. Knowing a bit of Unity this really means
> > it failed for MyClass or *any* of it’s dependencies. Ninject’s error