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
You Used To Inject Me In Your Constructor
Search
mathonsunday
December 14, 2015
Programming
690
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
49
Prepping For A SwiftUI Future
mathonsunday
0
560
Developing And Testing Complex Permission Flows
mathonsunday
1
240
We Have A Code Of Ethics: Now What?
mathonsunday
0
170
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
95
Other Decks in Programming
See All in Programming
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
430
mrbgem 三角測量 開発
ogom
0
180
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
Agents on Rails - Rails at Scale 2026
irinanazarova
0
310
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
750
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
210
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.3k
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
390
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
260
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
33
14k
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
300
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
430
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.2k
Marketing to machines
jonoalderson
1
5.8k
Odyssey Design
rkendrick25
PRO
2
850
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
860
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
sira's awesome portfolio website redesign presentation
elsirapls
0
430
Product Roadmaps are Hard
iamctodd
55
13k
How to Ace a Technical Interview
jacobian
280
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Raft: Consensus for Rubyists
vanstee
142
7.7k
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