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
78
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
180
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
Symfony + NelmioApiDocBundle を使った スキーマ駆動開発 / Schema Driven Development with NelmioApiDocBundle
okashoi
0
160
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
150
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
250
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
630
安いハードウェアでVulkan
fadis
0
290
The free-lunch guide to idea circularity
hollycummins
0
270
20260315 AWSなんもわからん🥲
chiilog
2
160
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
1k
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
130
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
570
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
6
1.8k
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
200
Featured
See All Featured
We Are The Robots
honzajavorek
0
200
Tell your own story through comics
letsgokoyo
1
850
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
140
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
410
Odyssey Design
rkendrick25
PRO
2
550
First, design no harm
axbom
PRO
2
1.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Bash Introduction
62gerente
615
210k
Being A Developer After 40
akosma
91
590k
Are puppies a ranking factor?
jonoalderson
1
3.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
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?