Login  Register

Re: Wiring objects, IoC and Service Locator

Posted by Ben Coman on Jun 08, 2017; 12:18am
URL: https://forum.world.st/Wiring-objects-IoC-and-Service-Locator-tp4949280p4950360.html



On Tue, Jun 6, 2017 at 11:48 PM, Attila Magyar <[hidden email]> wrote:
I don't think using a DI container worth the effort. They add lots of
complexities and solve very little. For some reason DI containers became
very popular in the Java world, but if you take a look at other programming
communities you'll realize that many people are perfectly happy without
using these containers. Using DI and using a DI container is orthogonal. As
you also said you can just pass dependencies to objects to achieve loose
coupling. Yes, you have to do this manually but what's the big deal? We're
talking about code with cyclomatic complexity of 1. Calling a constructor is
not a problem that need to be solved. Using an external XML configuration to
describe object wiring is the worst idea ever.

Here is an article about using plain old object composition to do DI

http://blog.davidpeterson.co.uk/2011/01/object-oriented-example.html

Some more thoughts about the problems associated with DI containers:

http://www.natpryce.com/articles/000783.html

I liked this...  "the [Dependency Injection] pattern also used to be called "third-party binding" or "third-party connect": some third party is responsible for connecting an object satisfying the service requirements of a component"
This makes the subject seem less esoteric.  It reminds me of hearing that the first (secret) task when doing a PhD is to invent new terms for common ones, and base your writings on that. Perhaps its the same for consultants and framework developers. ;P   Or maybe everything seems esoteric until you have experience with it and I've not done much with Java, certainly not big applications.  

Thx Peter for your example and how you prior experience compares to Pharo. 

cheers -ben 


http://higherorderlogic.com/2011/07/is-dependency-injection-like-facebook



--
View this message in context: http://forum.world.st/Wiring-objects-IoC-and-Service-Locator-tp4949280p4949720.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.