Hacker News new | ask | show | jobs
by galaktor 4883 days ago
Younger IoC frameworks aim for configuration in code, allowing for a much more dynamic usage.

Examples (c#) * Autofac * Ninject

1 comments

We use Guice which also allows that. But that doesn't address some of the key points he makes, such as - runtime x compile time wiring - wiring is based on types so injecting differently set up instances is difficult (we have a hell of Providers and different annotations to pick the right kind of instance injected) - non-transparency of the wiring process (sice it is performed by the magical IoC container)

I agree with a lot of what he writes. At the same time I believe there are cases where I would appreciate some kind of automation for wiring (f.ex. if I want a fresh instance for each session or request). And there are certainly cases when runtime wiring - as in the mentioned case of plugins - is useful.

I'm mostly familiar with Autofac, and there are many other ways to wire your app other than by type

* by interface * by enum * by parametrized constructor (Func<..>) * by (arbitrary) string * per process / per thread / per whatnot

Ninject actually does allow you to wire up with criteria beyond type based on the context into which the object is being injected.