# Dependency Injection Confidence: high Last verified: 2026-05-22 Generation: human_only ## TL;DR Dependency Injection (DI) is a technique where objects receive their dependencies from outside rather than creating them internally. It enables loose coupling, testability (mock dependencies), and centralized configuration. ## Core Explanation Types: constructor injection (preferred — immutable dependencies), setter injection (optional dependencies), interface injection. DI containers: Spring (Java), Angular, NestJS. Inversion of Control (IoC): the framework calls your code, not vice versa. DI is an implementation of IoC. ## Further Reading - [Inversion of Control Containers and the Dependency Injection pattern (Martin Fowler)](undefined)