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
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
19
Prepping For A SwiftUI Future
mathonsunday
0
500
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
78
Other Decks in Programming
See All in Programming
0から始めるモジュラーモノリス-クリーンなモノリスを目指して
sushi0120
0
210
[DevinMeetupTokyo2025] コード書かせないDevinの使い方
takumiyoshikawa
2
230
202507_ADKで始めるエージェント開発の基本 〜デモを通じて紹介〜(奥田りさ)The Basics of Agent Development with ADK — A Demo-Focused Introduction
risatube
PRO
6
1.3k
構造化・自動化・ガードレール - Vibe Coding実践記 -
tonegawa07
0
160
[SRE NEXT] 複雑なシステムにおけるUser Journey SLOの導入
yakenji
1
860
PHPカンファレンス関西2025 基調講演
sugimotokei
6
1k
副作用と戦う PHP リファクタリング ─ ドメインイベントでビジネスロジックを解きほぐす
kajitack
3
500
AWS Summit Japan 2024と2025の比較/はじめてのKiro、今あなたは岐路に立つ
satoshi256kbyte
1
260
코딩 에이전트 체크리스트: Claude Code ver.
nacyot
0
1k
11年かかって やっとVibe Codingに 時代が追いつきましたね
yimajo
0
220
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
3
1.5k
Streamlitで実現できるようになったこと、実現してくれたこと
ayumu_yamaguchi
2
250
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Why Our Code Smells
bkeepers
PRO
337
57k
How GitHub (no longer) Works
holman
314
140k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
1k
[RailsConf 2023] Rails as a piece of cake
palkan
56
5.7k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Statistics for Hackers
jakevdp
799
220k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
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