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
74
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
130
Efficient JSON to Object Parsing
swiftindia
0
110
Sign In with Apple
swiftindia
0
110
Furlenco's AR Journey
swiftindia
0
100
Image processing using Core Image and Metal
swiftindia
0
180
Combine - Diving into Apple’s Reactive Programming
swiftindia
1
210
Social in Hotstar
swiftindia
0
200
Improving App Launch Time
swiftindia
1
81
Backend Driven UIs
swiftindia
0
100
Other Decks in Programming
See All in Programming
最近のVS Codeで気になるニュース 2025/01
74th
1
250
Java Webフレームワークの現状 / java web framework at burikaigi
kishida
9
2.2k
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
240
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
170
Introduction to kotlinx.rpc
arawn
0
630
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
550
DROBEの生成AI活用事例 with AWS
ippey
0
130
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
180
Kubernetes History Inspector(KHI)を触ってみた
bells17
0
200
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
300
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
890
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
99
18k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
8
270
Faster Mobile Websites
deanohume
306
31k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Typedesign – Prime Four
hannesfritz
40
2.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Facilitating Awesome Meetings
lara
51
6.2k
Into the Great Unknown - MozCon
thekraken
35
1.6k
How to train your dragon (web standard)
notwaldorf
90
5.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
A Philosophy of Restraint
colly
203
16k
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?