Dependency Injection
- source
- Guice Motivation
Advantages
- Easy to write tests
- e.g.: classes with database instances
- Dependency is exposed by API signature, not hidden in the code
- after adding a new dependency
- no need to manually check the tests to find out which ones will fail
- no need to worry about forgot initializing the new dependency in the code