CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeremy D. Miller -- The Shade Tree Developer

Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

The Dependency Injection Application Block from Patterns and Practices

In case you've missed it, Grigori Melnik has announced that the forthcoming version of the EntLib will include a new application block for Dependency Injection.  I know there's been some level of disquiet about this announcement in ALT.NETish circles, but I think it's going to be a good thing.  I wrote a little bit about it before, but the key points for me are this:

  • Used well, Dependency Injection can do a lot of good in creating a modular design (and no, having TypeMock does not entirely replace the need for or value of DI).  Hopefully, more developers will be introduced to the concepts and usage of DI and Inversion of Control by the new DIAB.
  • From Gigori:  "...we plan to refactor individual EntLib blocks and abstract away configuration code (configurators)."  Jeremy's take:  EntLib classes will now be usable without having to muck with the configuration Xml.  I don't use EntLib in some small part due to my perception of it being "coding in Xml."
  • Patterns and Practices is reaching out to the OSS teams that have already built successful, working Inversion of Control containers.  I think that will alleviate some of the griping about ObjectBuilder from certain folks (like me).  Yes, it's another de facto competitor to working OSS tools from Microsoft, but at least they're being much more open and cooperative this time around.
  • You will be able to swap out the new DIAB for an existing IoC container like StructureMap in both the EntLib and the new WPF Composite client guidance/framework.  That's a huge deal in my book.  Just like the new MVC framework, the new WPF Composite client won't force a choice of IoC tool upon you.
Frankly, I don't see anything to get all that upset about.  All of us StructureMap/Windsor/Spring.Net enthusiasts need to remember that there are unenlightened shops that simply won't use any OSS tools -- and Microsoft choosing to promote any one of the existing IoC tools as the one true path would start a geeky civil war.

Published Dec 12 2007, 05:59 PM by Jeremy D. Miller
Filed under: ,

Comments

BigJimInDC said:

Having just failed in the fight to promote ALT.NET concepts on my current team, primarily due to arguments that what I was promoting just "wasn't what Microsoft was promoting" and therefore there aren't enough devs "out there" that we could hire to support it, I'm all for Microsoft promoting these things, in hopes that the fight I just lost just might be the last.  From the likes of folks like Haack getting hired there, hopefully this is the beginning of a trend there to "legitimize" ALT.NET concepts to the uninitiated.

# December 12, 2007 7:29 PM

ActiveEngine Sensei said:

The strength of ALT.Net is that it has extended the boundaries of the solution toolkit, whereas if you stick with the standard MSDN issue of solutions you can get locked into your own toolkit.  If it's not on MSDN, it's not worth looking into.  In the end this will limit your mastery of development skills as you won't be forced to examine why you are doing things, and how those things are directly or indirectly related to other disciplines.  

Yes it is cool that Microsoft if giving a nodd to ALT.Net.  It may open the floodgates for other innovations.

# December 12, 2007 9:41 PM

Joe Ocampo said:

This makes a lot of sense for organization who are not allowed to take advantage of OSS tool sets. Now they have a best practice approach that is actually a best practice and the support of MS.

Win win for everyone.

# December 13, 2007 10:13 AM

Jeff Perrin said:

Holy crap. Grigori was an instructor of mine, and my first boss as a software developer. I had no idea he was at Microsoft until I read this post. Dude is a manic Russian genius.

# December 13, 2007 7:40 PM

Solomon Duskis said:

InfoQ has picked up  on this story... I added this entry to the comment list.  I'm sure that your comments would be extremely relevant there...

www.infoq.com/.../entlib4_dependencyinjection

# December 14, 2007 9:59 AM

Matt Ellis said:

Hi Jeremy. I'm just wondering what you see the difference in EntLib's "coding in xml" and all the xml required to define a DI container?

(I'm not trolling, just trying to understand why DI is such a hot topic)

Cheers

Matt

# December 17, 2007 9:50 AM

Jeremy D. Miller said:

@Matt,

A couple points:

* The crucial difference is that classes that get everything through the constructors are completely decoupled from any configuration.  Think about that.  Once the EntLib is really "bootstrappable" through constructor functions you'll be able to more easily slice off little bits and pieces of the EntLib and reuse those classes without any Xml whatsoever or some entirely different form of configuration.  It's what I think of as "push" configuration versus "pull" configuration.  It's very valuable to decouple code that provides services from its configuration.  It's easier to write tests and much, much easier to reuse code.  All of my configuration is done with StructureMap, but if you threw away StructureMap you'd still be able to use all of my classes.  

structuremap.sourceforge.net/ConfigurationManagement.htm

* I don't know about Spring, but StructureMap and Windsor both have purely programmatic API's for configuration to avoid Xml almost altogether.  Actually, that's the way that I'd recommend going.  Less chance for screwing up and less junk to deploy.

# December 17, 2007 10:08 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jeremy D. Miller

Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy previously worked as a systems architect building mission critical supply chain software for a Fortune 100 company and learned agile development practices as a .Net consultant at ThoughtWorks, one of the pioneers of agile development. Jeremy is the author of the open source StructureMap (http://structuremap.sourceforge.net) tool for Dependency Injection with .Net and the forthcoming StoryTeller (http://storyteller.tigris.org) tool for supercharged FIT testing in .Net. Jeremy's thoughts on just about everything software related can be found on his weblog "The Shade Tree Developer" at http://codebetter.com/blogs/jeremy.miller, part of the popular CodeBetter site. Jeremy is a Microsoft MVP for C#. Check out Devlicio.us!

Our Sponsors

This Blog

Syndication

News

All opinions expressed here constitute my (Jeremy D. Miller's) personal opinion, and do not necessarily represent the opinion of any other organization or person, including (but not limited to) my fellow employees, my employer, its clients or their agents.

About Me

"Best Of" Compendium

StructureMap (Dependency Injection for .Net)

StoryTeller (Supercharged Fit)

Build your own Cab

TestDriven

MVP