https://kotlinlang.org logo
#android
Title
# android
m

matt tighe

10/03/2018, 4:51 PM
if i were to add DI to an already established project, is it worth considering Koin at this point, or is Dagger 2 still the suggested route?
a

alexsullivan114

10/03/2018, 4:53 PM
I looked through Koin the other day and was kind of disappointed. But I've also been frustrated with how difficult Dagger 2 has been to setup. Lately I've just been doing manual DI
d

dknapp

10/03/2018, 4:53 PM
that’s a fairly subjective question. which are you more familiar with?
m

matt tighe

10/03/2018, 4:58 PM
Neither. I’ve been doing all my dependency management by hand, but I’m planning a larger refactor to decouple as much business logic as I can from the SDK (for the second time) and thought it might be time to look into it.
c

Casey Brooks

10/03/2018, 5:08 PM
While I haven’t actually used Koin, it does look more like an abstraction over a Factory Pattern more than actual DI (it doesn’t implement the JSR330 interface for an injector). My guess is that it would be easier for initial setup and work well for small projects, but it just wouldn’t scale well for larger projects, and doesn’t automatically adapt to refactoring like a DI framework would. That being said, Dagger 2 took me a really long time to get set up correctly, but now that it’s in place, it was 100% worth the effort. The nature of code-gen makes it work a bit differently than a runtime DI framework like Spring or Guice, but once you wrap your mind around how it works and how to set it up, you really do use it in pretty much the same way as those runtime libs, just with significantly better performance. And unlike Koin, Dagger will scale infinitely for you and stands up against refactoring, and you’ll really start to notice the benefits when building an app with many independent modules.
👍 3
m

matt tighe

10/03/2018, 5:49 PM
Thanks for the detailed response.
r

rkeazor

10/03/2018, 7:20 PM
Dagger 2 is supported by Google , so it's definitely the preferred way... Koin isn't completely DI framework
j

Joe

10/04/2018, 6:21 AM
I have been using Kodein and been very happy with it. I felt like Dagger had too much cruft, though I have always been wary of DI through attributes. But that's just personal preference, of course.
e

Egor Trutenko

10/04/2018, 7:15 AM
Thumb up for Kodein
4 Views