Re:Dependency injection on Android with dagger-android and K...
by V-2 on Wednesday April 18, 2018 @04:19AM
(#16865658)
For simple scenarios DI is obviously an overkill, but as soon as you're dealing with nested dependencies, you'd end up with either:
* monstrously big constructors (for carrying transitive dependencies)
* lots of @VisibleForTesting code to handle manually injecting various dependencies only for the sake of testing (poor man's DI and generally bad practice)
* a lot of factories (service locator or poor man's DI, essentially)
* code that's hard to unit test due to dependencies being hardcoded.
In other words, you'll either reinvent DI poorly, or give up on testability.
* monstrously big constructors (for carrying transitive dependencies)
* lots of @VisibleForTesting code to handle manually injecting various dependencies only for the sake of testing (poor man's DI and generally bad practice)
* a lot of factories (service locator or poor man's DI, essentially)
* code that's hard to unit test due to dependencies being hardcoded.
In other words, you'll either reinvent DI poorly, or give up on testability.