# Dependency Injection

*noun*

say it: **“dih-PEN-den-see in-JEK-shun”** **/dɪˈpɛndənsi ɪnˈdʒɛkʃən/**

Handing a class the objects it needs from outside instead of letting it create them itself.

## What is **Dependency Injection**?

**Dependency injection** means giving a class the things it needs (usually through its constructor) instead of the class creating them itself. It makes code easier to test and to change.

```csharp
// The caller decides which sender to use
var service = new OrderService(new FakeEmailSender());
```

## In a sentence

- “With **dependency injection**, tests give OrderService a fake email sender.”

Level: Freelancer · [More OOP terms at this level](https://www.ask-codey.com/glossary?category=oop&level=4)

Updated: November 9, 2026

## In other subjects

- [Dependency Injection in Angular](https://www.ask-codey.com/glossary/dependency-injection-angular)
- [Dependency Injection in ASP.NET Core](https://www.ask-codey.com/glossary/dependency-injection-aspnet-core)

Source: https://www.ask-codey.com/glossary/dependency-injection
