Talk about Dagger 2 basics, dependency injection basics and alternative tools, and best practices of using Dagger 2 for Android Java projects. Dagger and Koin for Kotlin touched only very quickly
non final and non private fields • Forget an @Inject - get NullPointerException on a field • Constructor injection = immutable and thread safe objects. Protect from partially constructed state • For objects, constructed by the system (Activities, Fragments) - still use field injection
invoke the method instead of having to create a module instance. That method call can be inlined by the compiler • All bindings being static will result in a sizable performance increase • Make your modules abstract and Dagger will fail at compile time if one of the @Provides methods isn’t static
• Mert Simsek “New Android Injector with Dagger 2” • James Shvarts “Demystifying the new Dagger Android Injection API” • Fernando Cejas “Tasting Dagger 2 on Android” • Miroslaw Stanek “Dagger2 - graph creation performance” • CodePath’s guide to Dagger2 • Xoxol_89 @ Habrahabr “Dagger 2. Часть третья. Новые грани возможного” • Dagger2 official page