Koin vs Kodein - Dependency Injection what you prefer? Kotlin [closed]
Asked Answered
M

1

27

What dependency injection for Android with Kotlin do you prefer? I have started using Kodein but i don't want to lose my time if Koin it's better.

I have read this presentation https://www.kotlindevelopment.com/koin-vs-kodein/ by Makery Kotlin Development it's really nice.

From that presentation these are the differences:

Kodein

  • Robust
  • Tons of feature
  • Great documentation
  • More complicated API

Koin

  • Smaller
  • Less feature
  • Natural API

Github stars Kodein 1164 vs 1350 Koin


Thanks !!

Moribund answered 13/7, 2018 at 8:8 Comment(1)
This is a very opinionated, sweeping statement without any substance to it. While it's important to understand the shortcomings of Koin (which is essentially a service locator rather than a proper DI framework), it's a very viable alternative for projects of moderate size. Dagger 2 is more complex and requires more boilerplate, not to mention it adds up to the build time. It may be an overkill for a lot of Android projects, where the use of DI typically boils down to nothing else but substituting dependencies with mocks for testing purposes. (I can't comment on Kodein as I haven't used it)Vaughn
C
17

As my project is small I prefer Koin, because is lightweight library. It has a good API for scopes and wrapper for VM from Android Architecture Components. But you should know that Koin looks like Service Locator.

Conjugal answered 13/7, 2018 at 10:16 Comment(4)
Is Service Locator better than Dependency Injection?Neckerchief
@Neckerchief you should prefer patterns or tools based on your situation in the project. I think if you sure that your project is small and you don't need complex solution for IoC, then you can choose Koin or you can manual insert of dependencies. You can see a better explanation here reddit.com/r/androiddev/comments/8ch4cg/…Conjugal
Thanks for that link. According to the discussion there, there is no silver bullet, and nobody knows how to pick the best pattern for the job at hand :)Neckerchief
@Neckerchief Not at all. You absolutely right, no silver bullet. :)Conjugal

© 2022 - 2024 — McMap. All rights reserved.