Dependency injection

/dɪˈpɛndənsi ɪnˈdʒɛkʃən/ noun phrase

Definition

A design pattern where an object receives its dependencies from external sources rather than creating them internally. This promotes loose coupling and makes code more testable and maintainable.

Etymology

The term combines 'dependency' from Latin 'dependere' meaning to hang from, with 'injection' from Latin 'injicere' meaning to throw in. The pattern was formalized in object-oriented programming during the 1990s as part of inversion of control principles.

Kelly Says

Dependency injection is like having a personal assistant who brings you exactly the tools you need for each job, rather than you having to go fetch them yourself! This makes your code much easier to test because you can give it fake tools (mocks) to see how it behaves.

Related Words

Explore More Words

Get the Word Orb API

Complete word intelligence in one call. Free tier — 50 lookups/day.