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
You Used To Inject Me In Your Constructor
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
mathonsunday
December 14, 2015
Programming
670
0
Share
You Used To Inject Me In Your Constructor
Presented at Functional Swift Conference 2015.
mathonsunday
December 14, 2015
More Decks by mathonsunday
See All by mathonsunday
Pushing SwiftUI To The Limit
mathonsunday
0
26
Prepping For A SwiftUI Future
mathonsunday
0
530
Developing And Testing Complex Permission Flows
mathonsunday
1
220
We Have A Code Of Ethics: Now What?
mathonsunday
0
150
Real World Mocking In Swift
mathonsunday
4
1.8k
Making Swift Even More Functional
mathonsunday
2
410
Making Swift Even More Functional (iOS Dev Camp DC)
mathonsunday
0
120
Friendly Open Source Projects
mathonsunday
0
82
Other Decks in Programming
See All in Programming
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
960
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
270
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
820
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
430
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
0
250
CDK Deployのための ”反響定位”
watany
4
780
GitHubCopilotCLIをはじめよう.pdf
htkym
0
190
10 Tips of AWS ~Gen AI on AWS~
licux
5
410
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
220
実践CRDT
tamadeveloper
0
570
Back to the roots of date
jinroq
0
180
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
170
Making Projects Easy
brettharned
120
6.6k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
BBQ
matthewcrist
89
10k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
New Earth Scene 8
popppiees
3
2.1k
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
[SF Ruby Conf 2025] Rails X
palkan
2
960
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Transcript
You Used To Inject Me In Your Constructor - Functional
Programming In Swift
Hello, I’m Veronica Ray!
–Dependency Injection Demystified “Dependency injection means giving an object its
instance variables. Really. That's it.”
WHY
None
WHY •Clear declaration of dependencies •Composition •Easy customization
WHY •Clear ownership •Testability
FRAMEWORK
None
LAYER OF ABSTRACTION
SUPER LINEAR
SMART FRAMEWORKS
LAZY EVALUATION
–HaskellWiki “…expressions are not evaluated when they are bound to
variables, but their evaluation is deferred until their results are needed by other computations. ”
–HaskellWiki “…Pure computations ..can be performed at any time and
still yield the same result.
–HaskellWiki “This makes it possible to defer the computation of
values until they are needed, that is, to compute them lazily. ”
Lazy evaluation Brought to you by functional programming
MEMOIZATION
–Python 3 Tutorial “ If the same input or a
function call with the same parameters is used, the previously stored results can be used again and unnecessary calculation are avoided.”
SCOPES
TYPHOON
TyphoonScopeSingleton TyphoonScopeLazySingleton
SWINJECT
ObjectScope.Container
None
None
ISSUES
WE NEED A RESOLUTION
DI IN SWIFT •constructor injection •reader monad
DI IN SWIFT •constructor injection •reader monad
BearWithMe Find fiends to hibernate with during the winter
None
None
None
None
–In today’s post-OO world, is dependency injection still relevant? “Currently
we use the same mechanism – parameters – to define the environment (e.g. via constructor parameters), as we use to pass data around functions.”
DI IN SWIFT •constructor injection •reader monad
–Don’t Fear The Reader “…if you break down common dependency
injection libraries they are just different implementations of the Reader Monad pattern.”
None
None
SIMPLE EXAMPLE
DO NOTATION
DESUGARED
SWIFT
BearWithMe Find fiends to hibernate with during the winter
None
None
IS THIS A GOOD IDEA?
USE DEPENDENCY INJECTION
LEARN MORE
•Swiftz •Swift Injection •Nick Santos •objc.io •adit.io
THANK YOU