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
140
Sign In with Apple
swiftindia
0
140
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
250
Social in Hotstar
swiftindia
0
250
Improving App Launch Time
swiftindia
1
110
Backend Driven UIs
swiftindia
0
130
Other Decks in Programming
See All in Programming
Devoxx BE - Local Development in the AI Era
kdubois
0
130
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
13
4.8k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
CSC509 Lecture 03
javiergs
PRO
0
340
その面倒な作業、「Dart」にやらせませんか? Flutter開発者のための業務効率化
yordgenome03
1
130
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
200
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
3
900
Software Architecture
hschwentner
6
2.3k
スマホから Youtube Shortsを見られないようにする
lemolatoon
27
33k
Web フロントエンドエンジニアに開かれる AI Agent プロダクト開発 - Vercel AI SDK を観察して AI Agent と仲良くなろう! #FEC余熱NIGHT
izumin5210
3
550
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
130
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
3.3k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
53
7.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Git: the NoSQL Database
bkeepers
PRO
431
66k
How GitHub (no longer) Works
holman
315
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
How to Think Like a Performance Engineer
csswizardry
27
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Into the Great Unknown - MozCon
thekraken
40
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?