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
670
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
21
Prepping For A SwiftUI Future
mathonsunday
0
530
Developing And Testing Complex Permission Flows
mathonsunday
1
220
We Have A Code Of Ethics: Now What?
mathonsunday
0
150
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
120
Friendly Open Source Projects
mathonsunday
0
80
Other Decks in Programming
See All in Programming
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.4k
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
580
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
450
Oxlintはいいぞ
yug1224
5
1.2k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
670
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
270
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
370
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
6.1k
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
390
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
430
CSC307 Lecture 07
javiergs
PRO
0
530
2026年 エンジニアリング自己学習法
yumechi
0
120
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
310
The Limits of Empathy - UXLibs8
cassininazir
1
210
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
420
KATA
mclloyd
PRO
34
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
320
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
30 Presentation Tips
portentint
PRO
1
200
Between Models and Reality
mayunak
1
180
Paper Plane
katiecoart
PRO
0
46k
Navigating Team Friction
lara
192
16k
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