bernaferrari•

Kodein is nice, but Jake Wharton always says to not use it and go with Dagger instead. I started learning Dagger on the past few months and (except for a few troubles) has been very pleasant, easy and I really enjoyed it.

3
nhaarman•

You shouldn't take anything anyone says as an absolute truth. Think for yourself, be skeptical and find things out for yourself.

3
bernaferrari•

I do, but when the guy has a deep knowledge of how every inch of Android works, contributes to the biggest and best projects, and is the #1 kotlin developer in github stars worldwide, I'd rather get it wrong with him, Zhuinden and Vasiliy than get right with a blog post.

1
desmondtzq•

Just to point out, they are where they are precisely because they remain skeptical and think for themselves. If you want to follow blindly, at least follow the way they think/work.

4
ZhuindenEpicPandaForce @ SO•

That's nice of you :) although I shouldn't pave any roads to hell, haha


Anyhoo, the tricky thing about about Koin/Kodein is that you're still writing your constructor invocations (which are auto-generated in Dagger), so your actual gain compared to creating single instance of classes in order in Application.onCreate() and expose them as lateinit var is minimal.

In Java the problem was that calling constructors in the wrong order was runtime NPE, but with Kotlin that's compile time error.

So if you want to write constructor invocations, then Koin/Kodein is great - the question is what you actually get versus just doing it without Koin/Kodein in Application.onCreate().


If it's a question of syntax, a few weeks ago there was a post that showed how to use a singleton component and create a custom delegate so that you can use Dagger with a val myObject by inject { myObject() } instead of member injections. Possibilities are endless.

I stand by what I tend to say: Dagger is great if you have a dependency that depends on a dependency that depends on a dependency. If that's the problem you have, Dagger is the one that will actually solve it.

If that's not a problem you have, then you can have some lateinit vars vals initialized by hand and it'll still be OK.

2