Geeks With Blogs
Mike Nichols - SonOfNun Technology If I were the captain on a big steamboat...

Since I want to use words like "Repository" and "DDD" (ok, that's an acronym not a word) I have been slamming my head against Eric Evans' and Jimmy Nilssons' Domain Driven Design books in tandem. I get the same feeling when reading Evans' book that I used to get when I was playing jazz gigs in town (drummer) and some horn player would show up that was a blast to play with....only to find out later that he was in Maynard Ferguson' band for years. I knew there was something there, I just didn't get it right away.

But the fog (or smog) is lifting and as I had figured from the beginning Dependency Injection would be a valuable tool in the toolbox to help me with the loose coupling DDD promotes. So I was looking at the various DI tools out there and having read Jeremy Miller's blog alot and seeing a variety of folks who praise his Structure Map, I thought I'd start there.

After only having worked a couple of hours with it (shoudl have been less but I was half-brained on one part) I was able to greatly solidify how I am going to implement my Service Layer for my app and inject the dependencies on a Data Provider into my Domain Repositories AND be able to test easily. I did this with about six attributes and four lines of XML. Crazy. Since I naturally make things harder than they should be, I was convinced I was doing something wrong until I got *meaningful* green lights in my Unit Tests.

There are other DI tools out there and I looked into Spring.NET, Castle Windsor, and PicoContainer.NET...Each has its own style and benefits but the maintenance of MORE XML files (I'm lazy) when I am already using NHibernate pushed me away from them. But there may be a pleasant workaround I just didn't see. I like the attributes StructureMap offers and coupling that with patterns like Registry and his very cool IsSingleton property make testing a breeze (at least I think it will be :)).

Check this tool out if you are on the market for a *free* DI tool

Resources

Posted on Tuesday, August 15, 2006 1:00 PM General , OOP, Patterns, Architecture | Back to top


Comments on this post: Dependency Injection ala Structure Map

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Mike Nichols | Powered by: GeeksWithBlogs.net