Guess what I found in my inbox today…comments. I’ve never had comments before. It kind sucks that they came from rant.
Yesterday, I spent the day trying to pick an IOC container. I had a single clear requirement; take the username of the user from either Environment.UserName or HttpContext.Current.User.Identity.Username and pass it into my object. This assembly could be run from either ASP.NET or Windows Forms, so it would be nice if it were configurable. There are lots of ways I could do this, but I decided that it was time to pick an IOC container.
Hey, guess what? Every single IOC container in existance does this. So now what? Do I just stick the name of each one on a dart board, throw a dart, and that’s my new IOC container? Unfortunately, I don’t like random. I want to know which of these is the best choice for me and my team.
So, I start comparing them. I assume, that if multiple people went to the trouble of building and maintaining several different IOC containers, that there must be a reason for that. So, what do I want? I am not really a fan of XML configuration. I don’t really want to litter my code with attributes or tie it to a specific dependancy. I want a large enough community that I can get feedback and help from other people and know that bugs are going to get fixed. Where does that leave me? Still with too many choices.
I am hesitant to just pick one and go with it. The problem with a lot of development shops, including mine, is that once you pick a tool, it requires an act of God to switch to a different one. If I pick Unity today, and decide after a couple of months that StructureMap is a better fit, that’s fine for me, but a lot of my coworkers aren’t going to want to change without a compelling reason.
Logically, I know this decision doesn’t matter that much. I know I need to just pick one, learn it as best I can, use it, and I can adjust later if necessary. Tim Barcz has a great post on your IOC container not being a feature. Had I read this post before I spent the whole day weighing my options, I might have just picked one and ran with it instead of blogging my frustration for the whole world to see.
Just to clarify a few things from yesterday’s post:
- I don’t hate having alternatives, I hate not having enough information to make an intelligent choice
- I don’t hate open source. I wanted an IOC container in the .NET framework because it would have given me an obvious path forward. All the options I was considering were open source projects
- I don’t really like designers or drag-n-drop development. But writing code against six different dependancies with six different API’s and trying to make an informed decision made me wish for the simplicity of dragging a control onto a design surface.
- I blew a day of development, not because I didn’t have good options, but because I can’t seem to find good information on how to weigh them and I don’t know enough yet. Frankly, If I had 5 bad options and 1 good one, I wouldn’t have had anything to post.