Critical Thinking and Dissent is a Requirement

image So the fires continue to burn, as Joel Spolsky’s internet access hasn’t been disconnected.  For someone who is supposed to be an idiot and irrelevant, a lot of people still read and link to him.  I guess one guy is corrupting all the new developers, who are assumed to be reading Joel’s every word but in reality these developers probably didn’t know he existed until all these people linked to him saying he was wrong.

The lastest outrage seems to be this question on Stack Overflow: Why do I need an IoC container as opposed to straightforward DI code?

Now, before we get into the flames, let’s take a moment to actually look at the real question.  The use and benefits of Dependency Injection are not in question – not even by Joel.  The author has taken time to use the currently popular IoC and DI frameworks for his platform.  He is looking to understand the trade offs involved with using a framework and having to train his co-workers, and increasing the number of project dependencies.  Now, Joel’s response included:

The most valuable benefit of using an IoC container is that you can have a configuration switch in one place which lets you change between, say, test mode and production mode. For example, suppose you have two versions of your database access classes... one version which logged aggressively and did a lot of validation, which you used during development, and another version without logging or validation that was screamingly fast for production. It is nice to be able to switch between them in one place. On the other hand, this is a fairly trivial problem easily handled in a simpler way without the complexity of IoC containers.

Of course, we will ignore this sane and rational portion and focus on the one line zingers like:

I'm with you, Vadim. IoC containers take a simple, elegant, and useful concept, and make it something you have to study for two days with a 200-page manual.

...

I believe that if you use IoC containers, your code becomes, frankly, a lot harder to read. The number of places you have to look at to figure out what the code is trying to do goes up by at least one. And somewhere in heaven an angel cries out.

Never underestimate the power of developers to focus on a leaf in the middle of a forest.  In my view, this forest is using a framework versus using a pattern.  You could have DI by using Ninject (which I highly recommend to anyone looking for a DI framework), or you could roll your own DI (which I do quite commonly).

To many, these are mutually exclusive options and that one choice is always better.  This violates a core tenet of Agile – that we embrace change.  Each project should have a discussion if a framework is right for that project and that the decision is not permanent.  This extends beyond DI/IoC to every framework or line of code in the project – is it better to use an existing solution or roll our own?  There is no universal right answer here except “It Depends”.

Critical thinking and dissent on your team is a requirement for success.  If everyone accepts conventional wisdom (or worse, internet wisdom) without question, you might as hang up a sign that reads “because it’s always done that way.”

Posted By Mike On Thursday, October 08, 2009
Filed under agile developer di | Comments (2)

Submit this story to DotNetKicks   

Pete Shearer - Thursday, October 08, 2009 4:47:57 PM

I agree with you, Michael. Joel's point seemed to just be that sometimes an IoC framework is overkill and you can of course have DI without IoC. I didn't realize some of the uses of an IoC framework that were outlined in answers (sprinkling OnPropertyChanged notifiers over properties after the fact, for instance), but this isn't something that definitely needs used all of the time.

I don't agree 100% with ANYONE. I listen/read what they have to say, take what I can from it, and move on. All of this backlash seems like piling on for piling on's sake.

Roger Pence - Thursday, October 08, 2009 9:23:31 PM

I can't shake the feeling that Joel is working us. Given his outrageous (and hilarious) initial miscast of the single responsibility principle, his musing on the need for a git-er-done duct tape programmer, and now the missive on IOC/DI it sure seems to me that the only reason that Joel would say these things (he is, after all, a very smart and successful guy) is because it's good for business.

He rants. We rant. Always with his name in the middle of things. I respect Joel greatly, but feel like the days from learning from him are over (unless my career twists in an odd PT Barnum-like direction).

Leave a comment



Your name:
 

Your email (not shown):
 
Will display your Gravatar image.

Your website (optional):



About Michael

Michael C. Neel, born 1976 in Houston, TX and now live in Knoxvile, TN. Software developer, currently .Net focused. Board member of ETNUG and organizes CodeStock, East Tennessee's annual developers conference. .Net speaker, a Microsoft ASP.NET MVP and ASPInsider. Co-Founder of FuncWorks, LLC and GameMarx.

Proud father of two amazing girls, Rachel and Hannah, and loving husband to Cicelie who inflates and pops his ego as necessary.

 Subscribe to ViNull.com |  Comments

Follow me on Twitter | Contact Me

Related Posts

Game Development going Agile

Game review site Giant Bomb has a great article about Mass Effect 2’s development process.  The article is written by one of the review staff, who ... Read more

TeamCity.CodeBetter.com, A continuous integration server farm for open source projects

CodeBetter – in collaboration with JetBrains, IdeaVine, and Devlicio.us – is proud to announce the launch of TeamCity.CodeBetter.com – a continuous integration ... Read more

Being a Duct Tape Programmer

Things I’ve said in a session before: “Friends don’t let friends ORM” “ORM is a pattern, not a framework” “I like typed datasets, and I cannot lie” It’s ... Read more

Speaking at the Knoxville Agile Practitioner's Group

Thursday night (Jan 8th, 2009) I will be speaking at the Knoxville Agile Practitioner's Group on Dependency Injection.  I’m excited to do this session, ... Read more

XNA 3D Primer Published – Get a free copy!

In June of 2006 I officially became a professional author when ASP.NET Pro published my article “Google Can You Hear Me?”.  (So eager was I to be ... Read more

XNA 3D Primer by Michael C. Neel

XNA 3D Primer by Michael C. Neel
Buy Now: [ Amazon ] [ Wrox ]

GameMarx

CodeStock

ASPInsiders Member

ETNUG Member