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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
150
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
160
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
750
Getting Started with Vibe Coding
miccheng
0
220
小さなアプリを作って公開するまで
onozaty
0
180
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9.2k
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
15
12k
Spec-driven Development with AI
simas
PRO
0
2.3k
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
310
AI-Powered Domain-Driven Design
ziobrando
0
450
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
340
Featured
See All Featured
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
エンジニアに許された特別な時間の終わり
watany
109
250k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
New Earth Scene 8
popppiees
5
2.8k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
400
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Documentation Writing (for coders)
carmenintech
77
5.6k
Un-Boring Meetings
codingconduct
0
500
[SF Ruby Conf 2025] Rails X
palkan
3
1.5k
Into the Great Unknown - MozCon
thekraken
41
2.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k