Monday, February 25, 2013

Sacha say IOC you! Sacha Barber presents his BarbarianIOC...

CodeProject - BarbarianIOC : A simple IOC Container



Thing is I have always wanted to try and make one of these  myself, just to see what is involved. I did not want to go too nuts on this, and  just wanted the following really:

  1. Instance configuration : singleton / transient
  2. Simple registration process, maybe some sort of fluent interface
  3. Use the Expression API to compile into delegates for quick creation of  objects
  4. Constructor / property injection
  5. Provide the ability to accept non IOC held constructor parameters

So those couple of points are ALL I wanted to get working. As I say there are  a whole slew of full fledged IOC containers out there (where I have named a few  above), this articles container is more of a learning exercise, that I thought  I would share, in case anyone else is interested in this sort of thing.

I am calling my container BarbarianIOC as the existing  containers all seems to have these short snappy names, and it's kind of play on  my name, and if you saw me without a shave I do kinda look a bit like a  barbarian.

So there we go. That's essentially what this article is about, but just  before we get into the guts of it, please read this important note below.


I should point out that you should stick to using one of the major IOC containers out there,  as this was an exercise  to see what you needed to do to create your own. That is not to say I am not  happy with it, I totally am, and I think with more tinkering, I could make it  act near enough like one of the "proper" IOC containers out there, but I just know that,  that tinkering will never happen, as I am always  eager to move on to something new. So yeah just stick to using one of the big  "proper" IOC containers out there.

What Does It Do

In this section I will should you how to use BarbarianIOC, and  what that looks like in a typical application


Mare than anything I just like this Project's name... I've been meaning to jump into some real world IOC ("What? Greg, you're not IOC'ing every day in every app? ZOMG!" Yeah, yeah, I know... but my brain is only so big and I'm still trying was out the VB6'ness... sigh.. GC.Collect... GC.Collect.... ;)

Anyway, I like Sacha's past work and have learned a good bit from reading his articles, so this one looks like it's going to my "Must grok soon" list.

No comments: