There are various practices to get along with the best approach during software development. It’s always best to know about multiple paradigms to at least have an idea of the ease that comes with each approach. Good Problem solvers don’t stick to one rule or one programming language or one framework or one library but find a solution that suits them best for a particular problem. So, what if we have a lot of dependencies to manage?
Dependency injection can come in handy during this time.
Standard dependency injection comes with four roles
It includes objects containing functionality or dependent functionality
Are parts to connect with services
Any end object which behavior depends upon service it uses
It Injects any service required to the client
The Prime benefit of using dependency injection is decreased coupling between classes and their dependencies. I love dependency injection as it helps to reduce a lot of boilerplate code since all dependencies are handled by a singular component.
A Brief Outlook
Let’s say we have class C dependent on Class B and A. Dependency Injection will help to resolve Class A and B. This means I can depend on the end class C to focus on inputs and expected outputs.
I won’t detail this article as this article is intended to provide a quick overview only.
You might not require dependency in many cases, so make use when your project requires/has lots of dependencies to manage.
A SIDE NOTE
I will be contributing to this framework which is a remarkable initiative by Robin and wish other open source contributors to join him in this journey.
You can read the following article from the author to get more insights into the Box