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
Claude Code Skill入門
mayahoney
0
190
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
CSC307 Lecture 15
javiergs
PRO
0
240
Codex の「自走力」を高める
yorifuji
0
1.2k
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
5
810
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
420
Docコメントで始める簡単ガードレール
keisukeikeda
1
110
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
220
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
170
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.7k
Windows on Ryzen and I
seosoft
0
250
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
15
3k
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
130
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
140
ラッコキーワード サービス紹介資料
rakko
1
2.6M
Mobile First: as difficult as doing things right
swwweet
225
10k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Bash Introduction
62gerente
615
210k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
A Modern Web Designer's Workflow
chriscoyier
698
190k
A Soul's Torment
seathinner
5
2.4k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
250
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