# Dependency Injection

Handing a class the things it needs instead of letting it create them.

## 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());
```

Level: Freelancer · [More OOP terms at this level](https://www.ask-codey.com/glossary/subjects/oop/freelancer)

Updated: September 27, 2026

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