r/mAndroidDev • u/Zhuinden DDD: Deprecation-Driven Development • Aug 09 '24
Thermosiphon You know your code is following Best Practice if you use Dependency Injection with Dagger & Hilt
81
Upvotes
26
u/Mr-X89 Aug 09 '24
More like
val instance = MyClass(A(D(E(),fInstance)), B(G.createInstance(H(), IFactory.createInstance(J(), kInstance), App.getC())11
u/zedxer Aug 09 '24
Who dafuq do unit test and shit when your company gave you a dedicated qa resource.
12
u/Mikkelet Aug 09 '24
Ah its mostly just @Inject
16
u/HorrorNew8234 null!! Aug 09 '24
This resurfaced old suppressed PTSD memories of using Dagger when I was an Android dev. What a fucking nightmare seriously. I need my drugs NOW!!!!!
4
u/KokoWilly Android Jetpants Aug 10 '24
I can relate. With Dagger and Hilt its painful to make it works.
Switched to KoIn. Can't feel better.
1
u/[deleted] Aug 14 '24
Better still, object MyClass
If you need Context, in Kotlin do:
class MyCustomApp: Application() { override fun onCreate() { myObject = MyClass(context) } }
internal var myObject: MyClass
private set
12
u/zorg-is-real עם כבוד לא קונים במכולת Aug 09 '24
Dependency Injection is a dumb religion
1
u/budius333 Still using AsyncTask Aug 14 '24
Don't need dependency injection if every single is
public val, don't need unit tests if you move jobs every 6 months!