Talk:Dependency injection

Links

 * Dependency Injection: Vitally Important or Totally Irrelevant? a presentation by Jim Weirich at OSCON 2005
 * Dependency Injection in Ruby by Jim Weirich
 * Design Patterns: Dependency Injection by Griffin Caprio

Framework based DI Code Example
I highly discourage anybody from using hard coded strings in-line. The example in the last section of the page would be better if we added an static class to it that contains the strings: //static class provided by the framework or written by the user to indicate which dependencies are available public static class MyAvailableServices{ public static final string CarBuilderService = "CarBuilderService"; public static final string VanBuilderService = "VanBuilderService"; }

public class MyApplication { public static void main(String[] args) { Service service = (Service)DependencyManager.get(MyAvailableServices.CarBuilderService); Car car = (Car)service.getService(Car.class); car.setPedalPressure(5); float speed = car.getSpeedInMPH; } }
 * Strings are only used in code because they are easy to read. Using enums is much better and type safe to book. 194.207.86.26 (talk) 07:41, 22 December 2021 (UTC)

Registry Pattern
Should not this article reference the Registry Pattern which was very prevalent until IoC/DI was popularised?

Needlessly Object Oriented
Isn't the description needlessly presuming an object oriented approach? Dependency injection is just as easily performed in a classes programming language. It's the basis of how C's std library qsort operates: int cmpfunc (const void * a, const void * b) { return ( someMathWithAandB); }   qsort(array, size, sizeof(int), cmpfunc); — Preceding unsigned comment added by 97.122.84.35 (talk) 06:55, 28 November 2020 (UTC)
 * Classes programming is usually OO too. Also a program could be designed with OO principles but implemented with an non-OO language. eg:

194.207.86.26 (talk) 08:57, 22 December 2021 (UTC)


 * Dependency Injection is a fancy term for reference passing from the OOP world. The term Dependency Injection simply doesn't get much usage outside of OOP. Likely because the functional world already knows how to use composition.

Galhalee (talk) 04:00, 20 August 2022 (UTC)
 * It's not OOP; I've never heard of "injection" from within the OOP discipline, and I've been working with C++, Java, UML and design patterns for a long time. It is only since I've been working with server-side Java "Servlet" systems and browser-side Javascript AngularJS coding that I have heard of "injection". It's a bunch of hype intended to sound esoteric. I agree with earlier comment that it is nothing more/less than reference passing during startup.  "Injection" is a silly term for this, especially since it is only a startup function.  The word "injection" sounds like it should be something that could happen asynchronously, more than once, preemptively.