Talk:Dependency injection/Archives/2010/December

Delete this article
This article needs to be deleted along with Inversion of Control. Both are red herrings. Dependency injection = usage of callbacks and IoC = abstraction layer. For some unknown reason Martin Fowler and others in the software obfuscation industry have decided to rename concepts which already have perfectly good names. Wikipedia doesn't have to stand for this nonsense. Just because Martin Fowler and a few others sucking at the teat of Enterprise prefer Java to C doesn't mean Wikipedia has to follow his lead. Mistercupcake (talk) 07:31, 29 December 2007 (UTC)

The Martin Fowler article on this subject is highly dubious. He is trying to draw similarities between different frameworks, but the fact is that the frameworks really are essentially different. In fact the only thing you can say is that the frameworks use observer patterns and perhaps some data-directed configuration. Fowler and a few of his flunkies seem intent on slathering this admittedly powerful combination with vast amounts of pomo-esque hype... This is why software developers have a bad reputation amongst some clear-thinking individuals! DON'T BELIEVE THE HYPE!!! Remember: patterns are only good if they help you communicate with other developers. This is why they exist. Don't describe your work using patterns that are too fuzzy for their own good. Mistercupcake (talk) 07:23, 19 April 2008 (UTC)


 * I disagree with that observation. Dependency injection is about having an object being supplied with whatever dependencies it needs by an assembler. The responsability of invoking the injected behavior is still on the first object.


 * Inversion of Control may be seen as usage of callbacks. I mean, you use IOC when you define some behavior and tell a certain framework to invoke it when the time is right.


 * Fowler says that DI is an specific form of IOC. IMO, you can say that if you're talking about the container that does the injection for you. It seems to me that, from a framework user's point of view, Dependency Injection is a pattern used when you want to set up your objects graph, while Inversion of Control is used when you want some behavior invoked in response to a certain event.Ramiro Pereira de Magalhães (talk) 04:25, 30 December 2008 (UTC)


 * Yet the example given in the article simply exhibits one bad implementation of abstraction (using an interface, but the class using it needs to know about the details of that interface)--and then as the "good" example, displays what people have been (correctly) doing with interfaces for the last decade (or two). I'm having a very hard time seeing how IOC/DI isn't abstraction, but renamed and re-attributed.  And the presented example is absurd, in my opinion, because it is misusing the concept of an interface (why bother using an interface if the class is simply going to create a specific implementation?  It's silly) and then presenting the "fix" (i.e. the way most of the world prefers to use interfaces) as some new concept.


 * If DI is about "having an object being supplied with whatever dependencies it needs by an assembler" then let's get an example that shows whatever that is. But the current example is re-purposed "Interfaces for Dummies," except now attributed to Fowler, and I agree with Mistercupcake that something is rotten about this article. Jnoring (talk) 01:51, 14 February 2009 (UTC)


 * Yes, I've been thinking about the example for some time and never wrote something. At last, I wrote something that represents better what DI really is. It still needs some explanation about it, but I'll write it latter. See it below. Ramiro Pereira de Magalhães (talk) 14:04, 16 February 2009 (UTC)


 * Mistercupcake, do you think DI is just usage of callbacks? If so you don't understand. Daniel.Cardenas (talk) 02:30, 12 December 2010 (UTC)

Mistercupcake's opinions, and the opinions in response, are irrelevant; Wikipedia doesn't work that way. -- 98.108.225.155 (talk) 07:35, 10 December 2010 (UTC)

Making things explicit
(1) The obvious question about the term "dependency injection" is "what is being injected?" When I first heard the term I thought it meant that there were some kind of software objects called "dependencies" and that they were being injected into something. Now I suspect that it is OOP objects that are being injected and that the meaning is really "dependency-driven injection." I have no problem with the article being titled "dependency injection" but would like an explicit statement as to what is being injected. It also wouldn't hurt to give a software example of a dependency. The article mentions loading a driver and probably this is an example - the method depends on a driver to work - but this should be made explicit. (The example of the engine in a car is pretty helpful but an example in the realm of software - not too exotic - would also be helpful.) (2) THe article states "Dependency injection is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency. The term was first coined by Martin Fowler to describe the mechanism more clearly.[1]"

The word "dependency" in common usage refers to a relationship rather than an object. For example, "my code depends on driver x" means that there is a dependency of my code on the driver. "Dependency" in this case does not refer to my code, nor does it refer to driver x. Rather it refers (as I have said) to the relationship between my code and the driver.

The statement quoted above ("Dependency injection is a specific form...") contains the phrase "obtaining the needed dependency". Presumably this means obtaining the dependent object (the driver). But, not being an expert, I do not know for sure that this is what is meant. Does "obtaining the needed dependency" mean "obtaining the object on which the code depends?" If so then this should be stated. Gene.Naden (talk) 02:05, 14 December 2010 (UTC) — Preceding unsigned comment added by Gene.Naden (talk • contribs) 01:54, 14 December 2010 (UTC)