dependency injection
compound.compound. a way of writing computer code where one part of a program gets the tools it needs from the outside instead of creating them itself. This makes the code easier to test and change later.
compound. a design pattern in software engineering where an object receives its dependencies from an external source rather than instantiating them internally. This technique promotes loose coupling and enhances the testability of components by allowing dependencies to be easily swapped or mocked.
Dependency injection makes it easier to test our software.
By using dependency injection, the developer was able to swap the real database for a fake one during testing without changing the main code.
Implementing dependency injection through a dedicated framework allows for cleaner architectural boundaries, as high-level modules no longer need to manage the lifecycle or configuration of their low-level service providers.
A compound of dependency, from the Latin dependere meaning to hang from, and injection, from the Latin inicere meaning to throw in. The term was popularized by Martin Fowler in 2004 as a more descriptive alternative to the phrase Inversion of Control.
Etymology adapted from Wiktionary, available under CC BY-SA 4.0.
Commonly used in the context of object-oriented programming and software architecture.
Last updated July 22, 2026