Gabor Varadi
1 min readMay 4, 2020

--

This article at its core is “waging war against IoC containers” (and the JSR-330). Once you’ve thrown out the primary benefits of Dagger, a JSR-330 compliant IoC container (auto-resolution of dependencies for classes with @Inject annotated constructor), I’d wager it might be best to just not use Dagger at all. But are ‘IoC containers’ truly harmful? This is a topic worth investigating, as the idea of them being harmful is not new.

Personally, I’m not sold on the idea of the harmfulness of IoC containers and automatic dependency resolution at this time, and will continue to use @Singleton @Inject where I find it applicable.

Theoretically, JSR-330 ( @Inject, @Provider, @Named, @Singleton) was conceived of specifically so that there is a standard for various DI (IoC) implementations for sake of interoperability, therefore as long as DI is used in Java/Android only, I’m not convinced that this standard should be abolished, nor that “spreading the annotation across your codebase makes you reliant on a third-party framework.” These annotations belong to JSR-330 ( javax.inject.*), not Dagger.

--

--

Gabor Varadi
Gabor Varadi

Written by Gabor Varadi

Android dev. Zhuinden, or EpicPandaForce @ SO. Extension function fan #Kotlin, dislikes multiple Activities/Fragment backstack.

Responses (1)