Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Flipping the Koin @ GDG Dev Party
Search
Roberto Orgiu
May 02, 2020
Programming
86
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Flipping the Koin @ GDG Dev Party
Slides of my talk at GDG Dev Party Italy 2020
Roberto Orgiu
May 02, 2020
Transcript
39 slides
R O B E R T O O R G
I U - @ _ t i w i z Flippin’ the Koin
Is there a difference? IMPLEMENTATION DI vs SL
DI Container Should only call itself Never called by others
Constructs objects
Service Locator Container Dependency
I’m not really answering this question WHAT IS DAGGER?
@Inject lateinit var myTarget: Target myComponent.inject(this) val myTarget = myComponent.getTarget()
insert-koin.io
Why I like it Kotlin DSL Quick setup Easy to
follow
I’m not really answering this question either WHAT IS KOIN?
private val target: Target by inject() inline fun <reified T
: Any> ComponentCallbacks.inject()
modules declaration val myModule = module { single<Target> { TargetImpl()
} factory { (view: View) -> Presenter(view, get() } viewModel { MyViewModel(get()) } }
Injection private val target: Target by inject { parametersOf(this) }
Injection private val target: Target by inject { parametersOf(this) }
Injection private val target: Target by inject { parametersOf(this) }
Injection val viewModel: MyViewModel by viewModel()
Injection class MyWorker : KoinComponent { override suspend fun doWork():
Result { val target: Target by inject() ... } }
Application startKoin { androidContext(context) androidLogger() modules( listOf(module1,..., moduleN) ) }
Let’s talk about testing “
JUnit + KoinTest
Dependencies koinApplication { androidContext(context) modules(fetchModules()) }.checkModules()
Dependencies koinApplication { androidContext(context) modules(fetchModules()) }.checkModules { create<MyClass> { parametersOf(mock1,...,paramN)
} }
Building a test
startKoin class MyTest : KoinTest { @Before fun setup() {
startKoin { androidContext(context) modules(fetchModules()) } } }
startKoin class MyTest : KoinTest { @Before fun setup() {
startKoin { androidContext(context) modules(fetchModules()) } } }
startKoin stopKoin class MyTest : KoinTest { @After fun tearDown()
{ stopKoin() } }
startKoin stopKoin class MyTest : KoinTest { @After fun tearDown()
{ stopKoin() } }
startKoin stopKoin Test
class MyTest : KoinTest { @Before fun setup() { startKoin
{...} } @Test fun my_test() { } }
class MyTest : KoinTest { @Before fun setup() { startKoin
{...} } @Test fun my_test() { } } private val target: Target by inject() declareMock<Target>() given(target).will { throw Exception() }
Dagger VS Koin
WARNING: Opinionated Ideas ahead
We should use Dagger
Quick setup
Compile time safety Because we all love it.
Scalability
Maintainability
androiddevs.it
Use the tools You Like the most
Thanks!
More Decks by Roberto Orgiu
See All by Roberto Orgiu
Wellness & Droid
tiwiz
0
150
Behind the curtains
tiwiz
0
100
The Importance of Being Tested
tiwiz
0
470
An Android Dev start to Kotlin MPP
tiwiz
0
220
Fantastic API and where to find them
tiwiz
0
120
Flipping the Koin
tiwiz
2
190
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
140
Trip into the async world
tiwiz
1
170
GraphQL IRL (Android Makers)
tiwiz
0
170
Other Decks in Programming
See All in Programming
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
0
160
AI-Powered Domain-Driven Design
ziobrando
0
450
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
160
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
660
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2.1k
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9.2k
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
0
230
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.5k
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
150
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
230
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
350
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
55
8.4k
Evolving SEO for Evolving Search Engines
ryanjones
0
360
Unsuck your backbone
ammeep
672
58k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
980
Design in an AI World
tapps
1
390
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
400
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Optimising Largest Contentful Paint
csswizardry
37
4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
350
SEO for Brand Visibility & Recognition
aleyda
0
4.9k