Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
You Used To Inject Me In Your Constructor
Search
mathonsunday
December 14, 2015
Programming
0
660
You Used To Inject Me In Your Constructor
Presented at Functional Swift Conference 2015.
mathonsunday
December 14, 2015
Tweet
Share
More Decks by mathonsunday
See All by mathonsunday
Pushing SwiftUI To The Limit
mathonsunday
0
20
Prepping For A SwiftUI Future
mathonsunday
0
520
Developing And Testing Complex Permission Flows
mathonsunday
1
210
We Have A Code Of Ethics: Now What?
mathonsunday
0
140
Real World Mocking In Swift
mathonsunday
4
1.7k
Making Swift Even More Functional
mathonsunday
2
400
Making Swift Even More Functional (iOS Dev Camp DC)
mathonsunday
0
110
Friendly Open Source Projects
mathonsunday
0
80
Other Decks in Programming
See All in Programming
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
230
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.9k
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
130
開発に寄りそう自動テストの実現
goyoki
2
1.1k
これならできる!個人開発のすゝめ
tinykitten
PRO
0
110
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
2
220
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.7k
JETLS.jl ─ A New Language Server for Julia
abap34
1
420
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
350
チームをチームにするEM
hitode909
0
340
S3 VectorsとStrands Agentsを利用したAgentic RAGシステムの構築
tosuri13
6
340
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
500
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
GraphQLとの向き合い方2022年版
quramy
50
14k
Making Projects Easy
brettharned
120
6.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
Statistics for Hackers
jakevdp
799
230k
Code Reviewing Like a Champion
maltzj
527
40k
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