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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Roberto Orgiu
November 27, 2019
Programming
180
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
130
Behind the curtains
tiwiz
0
83
The Importance of Being Tested
tiwiz
0
440
An Android Dev start to Kotlin MPP
tiwiz
0
210
Fantastic API and where to find them
tiwiz
0
95
Flipping the Koin @ GDG Dev Party
tiwiz
1
78
Trip into the async world @ NYC Kotlin Meetup
tiwiz
0
130
Trip into the async world
tiwiz
1
150
GraphQL IRL (Android Makers)
tiwiz
0
160
Other Decks in Programming
See All in Programming
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
120
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
220
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
190
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
220
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
110
OSもどきOS
arkw
0
520
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
320
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
CSC307 Lecture 17
javiergs
PRO
0
320
Agentic UI
manfredsteyer
PRO
0
140
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
Exploring anti-patterns in Rails
aemeredith
3
400
A designer walks into a library…
pauljervisheath
211
24k
Six Lessons from altMBA
skipperchong
29
4.3k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
230
Visualization
eitanlees
152
17k
So, you think you're a good person
axbom
PRO
2
2.1k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
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!