DI
When a component (in the broad sense) in your application depends on others, those dependencies must be made available at runtime in one way or another. The manner in which dependencies are located, instantiated, and provided actually matters a lot. If you're not careful, you'll quickly create strong ties (that is, strong coupling) between different pieces of your application.
Down the line, unnecessary coupling leads to code that is harder to maintain, test, and debug.
DI, also known as Inversion of Control (IoC), is a design pattern that can help us to limit coupling and thus avoid those pitfalls. With that pattern, we can use a declarative approach rather than an imperative one to define our dependencies. Using DI/IoC, each component ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access