[ProgClub list] What is IoC?
asher.glynn at gmail.com
Tue Oct 11 21:31:29 AEDT 2011
> 1: My favorite at the moment is by Martin Fowler at
> Thanks for your explanation and links Stuart. I haven't read all your
> emails yet, but I will. I just wanted to throw in an off-the-cuff remark
> about this quote from Fowler:
> "In this article I dig into how this pattern works, under the more specific
> name of "Dependency Injection", and contrast it with the Service Locator
> alternative. The choice between them is less important than the principle of
> separating configuration from use."
> So it seems like the object of IoC is to separate configuration from use,
> and my knee-jerk reaction to that would be to use a factory. So from your
> example you would configure Notifier to use a factory to create its
> IMessageClient (which concretely might be a EmailSender) and if you want to
> configure Notifier some other way (for testing or improvement) then you
> could just create a different factory that created the new IMessageClient.
> In your testing code you'd configure a mock message client that just logged
> to the console or something like that, and in your production system you'd
> use a real IMessageClient implementation handed out by the factory.
> So far I don't see what IoC buys me, but I'll keep reading.
I thought I knew what IoC was about, however some back reading about it -
and Stuarts great writeup - not so certain any more. Certainly factory
methods seem to be a type of IoC from some descriptions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the list