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
92
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dependency Injection by Aadithya at SwiftDelhi
Dependency Injection by Aadithya at SwiftDelhi
Swift India
July 16, 2017
More Decks by Swift India
See All by Swift India
Network Layer Abstraction
swiftindia
0
190
Efficient JSON to Object Parsing
swiftindia
0
180
Sign In with Apple
swiftindia
0
180
Furlenco's AR Journey
swiftindia
0
160
Image processing using Core Image and Metal
swiftindia
0
260
Combine - Diving into Apple’s Reactive Programming
swiftindia
1
300
Social in Hotstar
swiftindia
0
280
Improving App Launch Time
swiftindia
1
160
Backend Driven UIs
swiftindia
0
160
Other Decks in Programming
See All in Programming
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
310
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
240
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.8k
the container ship “Apple Silicon”@WWDC26 Recap -Japan-\(region).swift
shingangan
0
130
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
800
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
150
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
770
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
420
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
630
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
520
AIが無かった頃の素敵な出会いの話
codmoninc
1
460
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
1.1k
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
My Coaching Mixtape
mlcsv
0
240
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
We Have a Design System, Now What?
morganepeng
55
8.3k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
530
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
870
Evolving SEO for Evolving Search Engines
ryanjones
0
260
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Embracing the Ebb and Flow
colly
88
5.1k
The Invisible Side of Design
smashingmag
301
52k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
430
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?