views:

208

answers:

2

I'm quite sure that IoC is the way to go for my application. There are a ton of articles and even questions here on SO that discuss the different containers. I've read several blogs today with partial examples. I am personally leaning towards starting with the CommonServiceLocator and Unity as two way to solve the same problem -- I just need a bunch of assemblies to get data from a database, which I assume is what needs to be injected everywhere.

I've yet to find any sites that really take a problem from beginning to end, with concrete code examples. For example, I've yet to find one that discusses an IServiceLocator and how to actually register it (or do whatever is required to make it known).

What are your favorite posts / articles / SO questions that can take a noob from start to finish with the implementation?

A: 

If you're still interested in using Unity, then the following screencast is worth the download - Unity IoC Fundamentals. While it does have real world examples at the end, unfortunately he absolutely flies through them - though there are links to blog posts further explaining the examples which you could go through at your own pace if interested.

Bermo
+2  A: 

If you haven't already read them, I recommend:

(I also recommend reading ploeh blog - Mark writes about DI as well as or better than anyone).

Neither provides an end-to-end application example, but together they provide a solid outline.

Fowler's article is critical to understanding the different types of dependency injection (and you may have already read it, based on your question), but I really had to read Hevery's article before I grokked how I'd use DI in the real world. (And you should read more of Hevery's stuff or Mark Seemann's "Service Locator is an Anti-Pattern", if only to understand why you shouldn't use service locator!)

Finally, one thing that I don't often see stated explicitly: your top-level applications are the only things that should reference your dependency injection framework classes.

Jeff Sternal