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
2
160
Flipping the Koin
Slides of the talk I gave at Kotlin/Everywhere in Stockholm, St. Petersburg and Milan
Roberto Orgiu
November 27, 2019
Tweet
Share
More Decks by Roberto Orgiu
See All by Roberto Orgiu
Wellness & Droid
tiwiz
0
120
Behind the curtains
tiwiz
0
66
The Importance of Being Tested
tiwiz
0
420
An Android Dev start to Kotlin MPP
tiwiz
0
180
Fantastic API and where to find them
tiwiz
0
76
Flipping the Koin @ GDG Dev Party
tiwiz
1
74
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
120
Trip into the async world
tiwiz
1
140
GraphQL IRL (Android Makers)
tiwiz
0
160
Other Decks in Programming
See All in Programming
並行開発のためのコードレビュー
miyukiw
2
2.2k
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
420
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
370
登壇資料を作る時に意識していること #登壇資料_findy
konifar
5
2.1k
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
140
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
660
atmaCup #23でAIコーディングを活用した話
ml_bear
4
720
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
190
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
230
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
120
AIプロダクト時代のQAエンジニアに求められること
imtnd
1
540
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Faster Mobile Websites
deanohume
310
31k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
83
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
63
53k
Docker and Python
trallard
47
3.8k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
170
Believing is Seeing
oripsolob
1
68
Measuring & Analyzing Core Web Vitals
bluesmoon
9
770
Test your architecture with Archunit
thirion
1
2.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
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!