Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Flipping the Koin
Search
Roberto Orgiu
November 27, 2019
Programming
170
2
Share
Flipping the Koin
Slides of the talk I gave at Kotlin/Everywhere in Stockholm, St. Petersburg and Milan
Roberto Orgiu
November 27, 2019
More Decks by Roberto Orgiu
See All by Roberto Orgiu
Wellness & Droid
tiwiz
0
130
Behind the curtains
tiwiz
0
72
The Importance of Being Tested
tiwiz
0
430
An Android Dev start to Kotlin MPP
tiwiz
0
190
Fantastic API and where to find them
tiwiz
0
85
Flipping the Koin @ GDG Dev Party
tiwiz
1
78
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
120
Trip into the async world
tiwiz
1
150
GraphQL IRL (Android Makers)
tiwiz
0
160
Other Decks in Programming
See All in Programming
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
350
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
230
iOS機能開発のAI環境と起きた変化
ryunakayama
0
190
Spec-driven Development: How AI Changes Everything (And Nothing)
simas
PRO
0
310
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
270
実用!Hono RPC2026
yodaka
2
270
AI-DLC Deep Dive
yuukiyo
9
4.8k
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
490
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
240
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
170
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
700
感情を設計する
ichimichi
5
1.6k
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
220
ラッコキーワード サービス紹介資料
rakko
1
3.1M
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Designing for Timeless Needs
cassininazir
0
210
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Bash Introduction
62gerente
615
210k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
We Have a Design System, Now What?
morganepeng
55
8.1k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Being A Developer After 40
akosma
91
590k
Embracing the Ebb and Flow
colly
88
5k
Transcript
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
Any questions? “
Use the tools You Like the most
Thanks!