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
190
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
140
Behind the curtains
tiwiz
0
94
The Importance of Being Tested
tiwiz
0
450
An Android Dev start to Kotlin MPP
tiwiz
0
210
Fantastic API and where to find them
tiwiz
0
110
Flipping the Koin @ GDG Dev Party
tiwiz
1
83
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
130
Trip into the async world
tiwiz
1
160
GraphQL IRL (Android Makers)
tiwiz
0
170
Other Decks in Programming
See All in Programming
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
130
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
2
500
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
240
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
0
450
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
120
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
680
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
3
460
初めての模倣学習とVLA
natsutan
0
500
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
290
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
140
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
390
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
540
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
GitHub's CSS Performance
jonrohan
1033
470k
Music & Morning Musume
bryan
47
7.4k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
430
Paper Plane
katiecoart
PRO
2
53k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The SEO Collaboration Effect
kristinabergwall1
1
550
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!