Design Patterns - Inversion of Control / Dependency Injection

design-patterns - Deep Dive into Dependency Injection and Writing

What is dependency injection?

If you class instantiate an object, we says that our class depends on that object. Instead of instantiating that object inside our class, we should move the code that instantiate the object outside our class. The code that use our class is responsible for creating the object that we need and provide it to us either by passing it to our constructor, or provide it to our class by invoking one of our setter method.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License