Dependency Injection
Dependency Injection (DI) is a software design pattern that enables us to develop loosely coupled code and is a great way to reduce tight coupling between software components. The D of the SOLID design principles stands for Dependency Inversion Principle (DIP), which states that "high-level modules should not depend upon low-level modules. Both should depend on abstractions". That is, it depends on abstractions, not on concrete implementations. If we speak in the language of the code, the class should not use new or static helper methods to populate its dependencies; it should rather have them injected. If you ever heard your architect or lead utter "program to interfaces, not implementations", it's because he/she wants ...
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