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
Dependency Injection by Aadithya at SwiftDelhi
Search
Swift India
July 16, 2017
Programming
0
77
Dependency Injection by Aadithya at SwiftDelhi
Dependency Injection by Aadithya at SwiftDelhi
Swift India
July 16, 2017
Tweet
Share
More Decks by Swift India
See All by Swift India
Network Layer Abstraction
swiftindia
0
170
Efficient JSON to Object Parsing
swiftindia
0
150
Sign In with Apple
swiftindia
0
150
Furlenco's AR Journey
swiftindia
0
140
Image processing using Core Image and Metal
swiftindia
0
230
Combine - Diving into Apple’s Reactive Programming
swiftindia
1
270
Social in Hotstar
swiftindia
0
260
Improving App Launch Time
swiftindia
1
120
Backend Driven UIs
swiftindia
0
140
Other Decks in Programming
See All in Programming
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
Basic Architectures
denyspoltorak
0
680
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.6k
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
140
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
AI & Enginnering
codelynx
0
120
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
920
Leo the Paperboy
mayatellez
4
1.4k
Optimizing for Happiness
mojombo
379
71k
New Earth Scene 8
popppiees
1
1.5k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
120
YesSQL, Process and Tooling at Scale
rocio
174
15k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
Un-Boring Meetings
codingconduct
0
200
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Designing Experiences People Love
moore
144
24k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
Transcript
Dependency Injection Adithya Reddy iOS engineer at UrbanClap
What. Why. How.
What is dependency Injection? It’s a fancy name for a
fairly simple concept.
Is DI used in this code snippet below? NO
What about this? YES
And this? NO
Traditional way: Race car Engine Transmission Piston Shaft Clutch Flywheel
Dependency injection way: Race car Engine Transmission Piston Shaft Clutch
Flywheel
Why use dependency Injection? 3 C’s Clarity Customizability Concerns
Clarity Callers need to know only about one thing, i.e.
initializer init() is clean and not dumped with constructors No unexpected behavior Example: if a new person joins the team, he need not go throught the viewcontroller to find the dependent objects in it. He just needs to look at init and inject.
Customizability Have control over which implementation to use. For example:
I can plug in Engine with FastEngine without worrying much Also, highly useful in testing. X1 in debug mode and X2 in release mode.
Concerns Race car is just a race car. Need not
worry about the configuration of other parts. Specific purposes lying in each component Allows composing instead of subclassing
Constructor injection vs Setter injection Constructor injection : use when
values dont change Setter injection : use when required. When you want to set the dependencies via properties
How to setup and use dependency injection? Now, I will
demonstrate how to integrate the Typhoon framework to achieve DI. Concept of Assemblies
Coming back… Now… you must be able to answer why
the code snippet below doesnt confirm to DI...
Why does this confirm to DI?
And finally, why doesnt this confirm to DI?