Inversion of Control

by Kofi Sarfo 4. June 2009 16:02

Our favourite piece of code seen recently is from a while ago: Building an IoC container in 15 lines of code. We like it because the intent is really very clear. Every now and then we find some use of Spring.NET or mention of IoC. Sometimes wonder whether it's necessary or being used because Developer-X wants to indicate sophistication. So then as a refresher we often end up here: Inversion of Control Containers and the Dependency Injection pattern. Written 35 Internet Years ago.

Looking at the way applications are written circa 2008 it appears IoC is reasonably common and therefore time to incorporate. Known advantages:

  • Decoupling
  • Service Orientation (is this repetition of the first?)
  • Testability
    • Allows mocking

The fact that we've neither been tripped up by object graphs nor troubled with dependency suggests not having done anything nearly enterprise enough. That, rather than an eidetic view of object relationships. Still, there's an argument for trying to incorporate a different approach into the ordinary as a means for seeing the ordinary for being less than splendid.

Right, so which one do we go for?

The nice thing about Autofac is that it's capable of using a delegate or Lambda Expression rather than reflection for component creation. As stated elsewhere, .NET 3.0 style. We like.

Notes:

Useful to make explicit the difference between Inversion of Control and Dependency Injection. Hint: The latter is a specific form of the former. Nice one, Wikipedia!

Tags:

Comments are closed

Kofi Sarfo modified theme by Mads Kristensen



Content by WIMIRO Technology is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.

Creative Commons License

Powered by BlogEngine.NET 1.5.0.7

About Me

Director, Wimiro Technology
London, United Kingdom

Writes in third person and first person plural; currently commutes to Moorgate.

Kiva Loans

  • Stalamarice Nthomo Kangi

    Stalamarice Nthomo Kangi

    Tailoring

    Requested loan: $375

    Amount raised: $0

    Machakos, Kenya

    To buy fabric

    Loan Now »

  • Jonathan Mututu Kasyoka

    Jonathan Mututu Kasyoka

    Internet Cafe

    Requested loan: $500

    Amount raised: $0

    Machakos, Kenya

    To buy more chairs, tables and printer paper

    Loan Now »

  • Jeanciana Rin

    Jeanciana Rin

    General Store

    Requested loan: $300

    Amount raised: $0

    Katutungan, Wao Lanao Del Sur, Philippines

    To purchase additional inventory and to use as working capital

    Loan Now »

 To see more entrepreneurs »

Kiva Loans