+ 1

What is depedency inversion principle?

The principle states : "High-level modules should not depend on low-level modules. Both should depend on abstractions." Can you make it clear by some example?

1st May 2019, 2:37 AM
Sujeet Agrahari
Sujeet Agrahari - avatar
1 Odpowiedź
+ 2
Inversion of Control and Dependency Injection are two concepts used in unit testing. When we unit test, we do not want the app to go to a database or call a service. So, if our high level module depends on using a low level module, then we can't unit test it. If our high level module depends on an interface, we can inject a mock/fake/stub for testing. Hopefully this code will help. Let me know if you need more information. https://code.sololearn.com/c16dDk3NKWtw/?ref=app
1st May 2019, 3:13 AM
Dan Stewart
Dan Stewart - avatar