View Single Post
  #1 (permalink)  
Old January 27th, 2011, 07:56 AM
MrFixxiT MrFixxiT is offline
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default IoC Container vs Service Locator

Dear Scott,

When discussing IoC Containers in chapter 8, you mention that your client code does not have to know about concrete implementations and it gets the right implementation injected.

I don't really see it I guess. You still need to wire up the dependencies in the Bootstrapper, which resides somewhere in the client. Actually the whole Resolve method looks like a Service Locator / Factory to me. You just specify that you want the concrete implementation of some interface and you will get it. How it knows what to get is in the bootstrapper.
The main difference is that by writing a Service Locator yourself, you have all the wiring code in the Locator and need a bit more work maybe, as with an IoC container you don't need to write the Locator, but just set it up. But both are somewhere in your client code.

Am I missing something?

What I do see is the auto-wireup of a dependency chain, which is very neat and does feel like a plus.
Reply With Quote