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
18
Prepping For A SwiftUI Future
mathonsunday
0
500
Developing And Testing Complex Permission Flows
mathonsunday
1
200
We Have A Code Of Ethics: Now What?
mathonsunday
0
130
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
業務自動化をJavaとSeleniumとAWS Lambdaで実現した方法
greenflagproject
1
110
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
360
人には人それぞれのサービス層がある
shimabox
3
670
Julia という言語について (FP in Julia « SIDE: F ») for 関数型まつり2025
antimon2
3
940
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
110
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
810
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
600
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
250
Blueskyのプラグインを作ってみた
hakkadaikon
1
540
セキュリティマネジャー廃止とクラウドネイティブ型サンドボックス活用
kazumura
1
170
赤裸々に公開。 TSKaigiのオフシーズン
takezoux2
0
130
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Adopting Sorbet at Scale
ufuk
77
9.4k
Thoughts on Productivity
jonyablonski
69
4.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
43
2.4k
What's in a price? How to price your products and services
michaelherold
245
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
RailsConf 2023
tenderlove
30
1.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Code Review Best Practice
trishagee
68
18k
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