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
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
Inside of Swift Export
giginet
PRO
1
250
ビルドプロセスをデバッグしよう!
yt8492
0
170
Introducing RemoteCompose: break your UI out of the app sandbox.
camaelon
2
240
Dive into Triton Internals
appleparan
0
350
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.6k
Vueのバリデーション、結局どれを選べばいい? ― 自作バリデーションの限界と、脱却までの道のり ― / Which Vue Validation Library Should We Really Use? The Limits of Self-Made Validation and How I Finally Moved On
neginasu
3
1.7k
AsyncSequenceとAsyncStreamのプロポーザルを全部読む!!
s_shimotori
1
190
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
110
퇴근 후 1억이 거래되는 서비스 만들기 | 내가 AI를 사용하는 방법
maryang
1
160
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
190
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
4
17k
Featured
See All Featured
Scaling GitHub
holman
463
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
Bash Introduction
62gerente
615
210k
Why Our Code Smells
bkeepers
PRO
340
57k
Done Done
chrislema
186
16k
Context Engineering - Making Every Token Count
addyosmani
8
320
How STYLIGHT went responsive
nonsquared
100
5.9k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Product Roadmaps are Hard
iamctodd
PRO
55
11k
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