🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Dependency Injection

In plain terms

Supplying a component's dependencies from outside instead of it creating them.

Going deeper

With DI, objects receive the services they need (via constructor or setter) rather than instantiating them, making code looser-coupled, easier to test, and more flexible to reconfigure.

Under the hood

Inverts control of dependency creation, improving testability via mocks; can be constructor, setter, or interface injection, often managed by a DI container/framework.

Examples

Spring, ASP.NET Core DI, Angular providers, constructor injection of repositories.

Think of it like...

Like a chef being handed the ingredients they need rather than going out to farm and source everything themselves.

Feedback & Bug Report