2 ms·
I think we are starting to argue about semantics here. This example is simply a very common way of coding to an interface, which BTW, duck-typing makes this so
by wyuenho 14y ago
I think we are starting to argue about semantics here. This example is simply a very common way of coding to an interface, which BTW, duck-typing makes this so much easier.
I think through out the whole discussion about DI in the past week or so is that people don't talk about the injectors themselves enough. Too many pseudo-experts talking about inconsequential and totally unrelated programming principles and paradigms.
I don't think people naturally object to coding to the interface, which this example illustrates very well its utility. I think detractors simply just hate the injectors, the people who use the bad injectors indiscriminately, and the stubborn people who insist on doing DI on an entire app.
My guess is, most people automatically jump to a DI framework not really because of DI, you can do DI with just a good old factory and may be a good configuration library. Most people jump to DI because of a framework, and the niceties that said framework offers. After a while, people just start confusing the effect with the cause.
Can we please start talking about what is DI, when would one find it useful, and what DI approach is suitable under what circumstances now?