Dependency What is a dependency relationship?
"A depends on B" means that when dependent B changes, it affects A
Let's look at the example below
Pizza shop chef relies on pizza recipe. When Pizza Recipes Changed
According to the changed recipe, the chef has to modify the way the pizza is made.
We can say that cooks depend on recipes because changes in recipes affect the behavior of cooks.
Advantages :
Increases reusability.
It's easy to test.
It also simplifies the code.
It also reduces the amount of dependent code.
It's easy to figure out why you're using it. It makes the code easier to read.
Dependencies are reduced. When a component's dependencies are reduced, it is less sensitive to change.
Flexibility and scalability can be improved while reducing coupling.
Dependencies between objects can be established.
Dependencies between objects can be removed or reduced.
Reference
https://medium.com/@jang.wangsu/di-dependency-injection-%EC%9D%B4%EB%9E%80-1b12fdefec4f