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
75
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
160
Efficient JSON to Object Parsing
swiftindia
0
130
Sign In with Apple
swiftindia
0
130
Furlenco's AR Journey
swiftindia
0
120
Image processing using Core Image and Metal
swiftindia
0
210
Combine - Diving into Apple’s Reactive Programming
swiftindia
1
240
Social in Hotstar
swiftindia
0
240
Improving App Launch Time
swiftindia
1
100
Backend Driven UIs
swiftindia
0
130
Other Decks in Programming
See All in Programming
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
20
11k
Design Foundational Data Engineering Observability
sucitw
3
200
AIと私たちの学習の変化を考える - Claude Codeの学習モードを例に
azukiazusa1
10
4.1k
テストカバレッジ100%を10年続けて得られた学びと品質
mottyzzz
2
590
Navigation 2 を 3 に移行する(予定)ためにやったこと
yokomii
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
370
Ruby Parser progress report 2025
yui_knk
1
440
Updates on MLS on Ruby (and maybe more)
sylph01
1
180
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
300
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
もうちょっといいRubyプロファイラを作りたい (2025)
osyoyu
1
430
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.7k
Featured
See All Featured
Speed Design
sergeychernyshev
32
1.1k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Statistics for Hackers
jakevdp
799
220k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
It's Worth the Effort
3n
187
28k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Gamification - CAS2011
davidbonilla
81
5.4k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
The Language of Interfaces
destraynor
161
25k
GraphQLの誤解/rethinking-graphql
sonatard
72
11k
Balancing Empowerment & Direction
lara
3
620
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?