Dependency injection
A component receives dependencies from outside instead of creating concrete implementations itself.
What is dependency injection?
With dependency injection, a component receives required dependencies from outside, for example as constructor parameters. It does not have to create the concrete implementation itself. Assembling the parts is separated from using them. Ordinary program code can do this; the principle does not require a dedicated DI container.
In a fictional example, a report component is given a data reader. In operation it reads the intended source; for a focused test, a suitable test implementation can supply fixed data. This supports isolated checking but does not demonstrate correct connection to the real source. Lifetime, configuration and release of required resources still need decisions. DI is a specific form of inversion of control; not every inversion of control or service locator is DI.
Sources
Related terms
- Clean ArchitectureSeparating business rules from external details and directing source-code dependencies towards the core.
- Unit testA focused check of a small, defined part of software, such as a rule or function.
- Design patternA reusable solution structure for a recurring software design problem, with its own trade-offs.
- Cache stampedeA cache stampede occurs when concurrent cache misses trigger the same expensive calculation or data query repeatedly.
- BackpressureBackpressure adjusts incoming data to the receiver’s processing capacity through signals to slow down or pause.
- Race conditionA result depends on the timing of overlapping accesses and can therefore be wrong.
Your project with ASES
Describe your project to us. We will get back to you with an initial assessment.