independent of the concrete implementation. The differences is how the implementation is provided. - Service Locator: the class asks for it. - Every class has a dependency to the locator. - Injection: there is no explicit request.
val viewModel: MainViewModel by inject() // with Dagger @Inject lateinit var viewModel: MainViewModel With dagger there explicit request, so we cannot declare it a val Since it is provided from outside, it cannot be private.
DiskCacheImpl(gson: Gson) : DiskCache // with Dagger class DiskCacheImpl @Inject constructor(gson: Gson) : DiskCache @Inject violates separation of concerns. Impl should not know its being injected.
beginners. - Complicated, especially wanting to read generated code. - Annotation Processing increasing build times. - Lots of boiler plate code setting up components and modules and binder factories. - Setting up graphs for testing is difficult.
runtime. - Compile time validation. - Benefits increase with scale. - A lot of daggers problems (complexity, learning curve) are daggers and not the pattern it implements.