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
mathonsunday
December 14, 2015
Programming
680
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
39
Prepping For A SwiftUI Future
mathonsunday
0
550
Developing And Testing Complex Permission Flows
mathonsunday
1
230
We Have A Code Of Ethics: Now What?
mathonsunday
0
160
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
87
Other Decks in Programming
See All in Programming
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.8k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
210
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
500
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
8.8k
初めてのKubernetes 本番運用でハマった話
oku053
0
120
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
280
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
130
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
270
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.1k
Exploring anti-patterns in Rails
aemeredith
3
440
From π to Pie charts
rasagy
0
230
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
It's Worth the Effort
3n
188
29k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
RailsConf 2023
tenderlove
30
1.5k
For a Future-Friendly Web
brad_frost
183
10k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
270
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