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
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
37
Prepping For A SwiftUI Future
mathonsunday
0
540
Developing And Testing Complex Permission Flows
mathonsunday
1
230
We Have A Code Of Ethics: Now What?
mathonsunday
0
160
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
86
Other Decks in Programming
See All in Programming
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.1k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
480
A2UI という光を覗いてみる
satohjohn
1
130
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.5k
CSC307 Lecture 17
javiergs
PRO
0
320
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
250
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
260
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
220
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
130
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
160
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
210k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
Building AI with AI
inesmontani
PRO
1
1.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
Writing Fast Ruby
sferik
630
63k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
We Have a Design System, Now What?
morganepeng
55
8.2k
Are puppies a ranking factor?
jonoalderson
1
3.5k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
How GitHub (no longer) Works
holman
316
150k
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