Read more" />

๐Ÿคธโ€โ™€๏ธ Is Koin a Service Locator or a Dependency Injector? ๐Ÿค” The answer might surprise you! ๐Ÿคฏ

โ€œ๐˜›๐˜ฉ๐˜ฆ ๐˜ด๐˜ฉ๐˜ฐ๐˜ณ๐˜ต ๐˜ข๐˜ฏ๐˜ฅ ๐˜ด๐˜ช๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ ๐˜ข๐˜ฏ๐˜ด๐˜ธ๐˜ฆ๐˜ณ ๐˜ช๐˜ด ๐˜’๐˜ฐ๐˜ช๐˜ฏ ๐˜ช๐˜ด ๐˜ข ๐˜ฅ๐˜ฆ๐˜ฑ๐˜ฆ๐˜ฏ๐˜ฅ๐˜ฆ๐˜ฏ๐˜ค๐˜บ ๐˜ช๐˜ฏ๐˜ซ๐˜ฆ๐˜ค๐˜ต๐˜ช๐˜ฐ๐˜ฏ (๐˜‹๐˜) ๐˜ง๐˜ณ๐˜ข๐˜ฎ๐˜ฆ๐˜ธ๐˜ฐ๐˜ณ๐˜ฌ ๐˜ง๐˜ฐ๐˜ณ ๐˜’๐˜ฐ๐˜ต๐˜ญ๐˜ช๐˜ฏ, ๐˜ฐ๐˜ง๐˜ง๐˜ฆ๐˜ณ๐˜ช๐˜ฏ๐˜จ ๐˜ข ๐˜ฎ๐˜ฐ๐˜ฅ๐˜ฆ๐˜ณ๐˜ฏ ๐˜ข๐˜ฏ๐˜ฅ ๐˜ญ๐˜ช๐˜จ๐˜ฉ๐˜ต๐˜ธ๐˜ฆ๐˜ช๐˜จ๐˜ฉ๐˜ต ๐˜ด๐˜ฐ๐˜ญ๐˜ถ๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ง๐˜ฐ๐˜ณ ๐˜ฎ๐˜ข๐˜ฏ๐˜ข๐˜จ๐˜ช๐˜ฏ๐˜จ ๐˜บ๐˜ฐ๐˜ถ๐˜ณ ๐˜ข๐˜ฑ๐˜ฑ๐˜ญ๐˜ช๐˜ค๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏโ€™๐˜ด ๐˜ฅ๐˜ฆ๐˜ฑ๐˜ฆ๐˜ฏ๐˜ฅ๐˜ฆ๐˜ฏ๐˜ค๐˜ช๐˜ฆ๐˜ด ๐˜ธ๐˜ช๐˜ต๐˜ฉ ๐˜ฎ๐˜ช๐˜ฏ๐˜ช๐˜ฎ๐˜ข๐˜ญ ๐˜ฃ๐˜ฐ๐˜ช๐˜ญ๐˜ฆ๐˜ณ๐˜ฑ๐˜ญ๐˜ข๐˜ต๐˜ฆ ๐˜ค๐˜ฐ๐˜ฅ๐˜ฆ. ๐˜’๐˜ฐ๐˜ช๐˜ฏ ๐˜ข๐˜ญ๐˜ด๐˜ฐ ๐˜ด๐˜ถ๐˜ฑ๐˜ฑ๐˜ฐ๐˜ณ๐˜ต๐˜ด ๐˜ต๐˜ฉ๐˜ฆ ๐˜š๐˜ฆ๐˜ณ๐˜ท๐˜ช๐˜ค๐˜ฆ ๐˜“๐˜ฐ๐˜ค๐˜ข๐˜ต๐˜ฐ๐˜ณ ๐˜ฑ๐˜ข๐˜ต๐˜ต๐˜ฆ๐˜ณ๐˜ฏ [sic]โ€ (Kotzilla)

๐Ÿ‘‰ ๐—ž๐—ผ๐—ถ๐—ป ๐—ถ๐˜€ ๐—ฝ๐—ฟ๐—ถ๐—บ๐—ฎ๐—ฟ๐—ถ๐—น๐˜† ๐—ฎ ๐——๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐˜† ๐—œ๐—ป๐—ท๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป (๐——๐—œ) ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ, but itโ€™s sometimes mistaken for a Service Locator due to how it handles dependencies. The key difference lies in how dependencies are provided:

๐Ÿ’  ๐——๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐˜† ๐—œ๐—ป๐—ท๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—บ๐—ฒ๐—ฎ๐—ป๐˜€ ๐—ฑ๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐—ถ๐—ฒ๐˜€ ๐—ฎ๐—ฟ๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐˜ƒ๐—ถ๐—ฑ๐—ฒ๐—ฑ (๐—ผ๐—ฟ โ€œ๐—ถ๐—ป๐—ท๐—ฒ๐—ฐ๐˜๐—ฒ๐—ฑโ€) by an external framework (like Koin) to the class that needs them, typically through constructor injection or field injection. Koin supports this approach by resolving and injecting dependencies automatically based on the definitions you provide in its modules.

๐Ÿ’  ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐˜๐—ผ๐—ฟ ๐—ถ๐˜€ ๐—ฎ ๐—ฝ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป ๐˜„๐—ต๐—ฒ๐—ฟ๐—ฒ ๐—ผ๐—ฏ๐—ท๐—ฒ๐—ฐ๐˜๐˜€ ๐—ฟ๐—ฒ๐—พ๐˜‚๐—ฒ๐˜€๐˜ ๐—ฑ๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐—ถ๐—ฒ๐˜€ ๐—ฑ๐—ถ๐—ฟ๐—ฒ๐—ฐ๐˜๐—น๐˜† ๐—ณ๐—ฟ๐—ผ๐—บ ๐—ฎ ๐—ฐ๐—ฒ๐—ป๐˜๐—ฟ๐—ฎ๐—น๐—ถ๐˜‡๐—ฒ๐—ฑ ๐—ฟ๐—ฒ๐—ด๐—ถ๐˜€๐˜๐—ฟ๐˜† ๐—ผ๐—ฟ ๐—น๐—ผ๐—ฐ๐—ฎ๐˜๐—ผ๐—ฟ ๐—ฎ๐˜ ๐—ฟ๐˜‚๐—ป๐˜๐—ถ๐—บ๐—ฒ. While Koin has similarities to this pattern (because you can explicitly request instances from Koinโ€™s context), its primary mode of operation aligns more with Dependency Injection, as it manages object creation and wiring automatically for you.

โœ‹ The confusion comes from the fact that Koin offers both injection and resolution on demand (via functions like get()), but its core mechanism follows the DI approach.

๐Ÿ” So, to clarify: ๐—ž๐—ผ๐—ถ๐—ป ๐—ถ๐˜€ ๐—ฎ ๐——๐—ฒ๐—ฝ๐—ฒ๐—ป๐—ฑ๐—ฒ๐—ป๐—ฐ๐˜† ๐—œ๐—ป๐—ท๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ, ๐—ฏ๐˜‚๐˜ ๐—ถ๐˜ ๐—ต๐—ฎ๐˜€ ๐—ณ๐—ฒ๐—ฎ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ ๐˜๐—ต๐—ฎ๐˜ ๐—ฐ๐—ฎ๐—ป ๐—ฟ๐—ฒ๐˜€๐—ฒ๐—บ๐—ฏ๐—น๐—ฒ ๐˜๐—ต๐—ฒ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐˜๐—ผ๐—ฟ ๐—ฝ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป. ๐ŸŒŸ๐Ÿš€

๐Ÿ”— Find more info in this link

Call today

+34 634 548 126

You've found the person you were looking for. Let's talk.

Let's get you started