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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mathonsunday
December 14, 2015
Programming
680
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
You Used To Inject Me In Your Constructor
Presented at Functional Swift Conference 2015.
mathonsunday
December 14, 2015
More Decks by mathonsunday
See All by mathonsunday
Pushing SwiftUI To The Limit
mathonsunday
0
39
Prepping For A SwiftUI Future
mathonsunday
0
550
Developing And Testing Complex Permission Flows
mathonsunday
1
230
We Have A Code Of Ethics: Now What?
mathonsunday
0
170
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
91
Other Decks in Programming
See All in Programming
Claude Team Plan導入・ガイド
tk3fftk
0
250
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
180
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
160
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
540
Built Our Own Background Agent at LayerX #aidevex_findy
layerx
PRO
9
4.6k
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
450
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
1.1k
FDEが実現するAI駆動経営の現在地
gonta
2
250
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
140
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
170
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
1
110
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.2k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Test your architecture with Archunit
thirion
1
2.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Ruling the World: When Life Gets Gamed
codingconduct
0
290
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
370
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Leo the Paperboy
mayatellez
8
2.1k
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