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
22
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.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
82
Other Decks in Programming
See All in Programming
AHC061解説
shun_pi
0
350
今、アーキテクトとして 品質保証にどう関わるか
nealle
0
210
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.9k
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
380
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
180
TipKitTips
ktcryomm
0
160
SourceGeneratorのマーカー属性問題について
htkym
0
180
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
250
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
760
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
350
AI活用のコスパを最大化する方法
ochtum
0
130
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
120
Featured
See All Featured
A Soul's Torment
seathinner
5
2.4k
How to train your dragon (web standard)
notwaldorf
97
6.5k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
120
Navigating Team Friction
lara
192
16k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
440
How to build a perfect <img>
jonoalderson
1
5.2k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.1k
Designing for Performance
lara
611
70k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
780
Information Architects: The Missing Link in Design Systems
soysaucechin
0
820
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
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