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
Roberto Orgiu
May 02, 2020
Programming
84
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
More Decks by Roberto Orgiu
See All by Roberto Orgiu
Wellness & Droid
tiwiz
0
140
Behind the curtains
tiwiz
0
99
The Importance of Being Tested
tiwiz
0
460
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
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
2.8k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.3k
sbt 2.0: takeoff
eed3si9n
0
170
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.1k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
190
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
620
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
120
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
830
パスワード再設定メールのURLについて知っておこう
uyuki234
0
180
golang-bob.pdf
iwatsukayura
0
140
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
96
14k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
380
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
330
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
960
Amusing Abliteration
ianozsvald
1
350
Accessibility Awareness
sabderemane
1
260
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
640
YesSQL, Process and Tooling at Scale
rocio
174
15k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
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
androiddevs.it
Use the tools You Like the most
Thanks!