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
ドラ🔵もんでDIを学ぶ
Search
Tomoki Ota
June 21, 2024
Programming
0
5.6k
ドラ🔵もんでDIを学ぶ
ドラ🔵もんでDIと依存性逆転の注入を解説します。
コードの例など詳細な解説は以下で行なっています。
ドラ🔵もんで依存性の注入と依存性逆転の原則を理解する!!
Tomoki Ota
June 21, 2024
Tweet
Share
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
93
アーキテクチャとビジネスロジック
tomo1227
0
92
【Go言語】テスト
tomo1227
0
53
【Go言語】クロージャ
tomo1227
0
260
【Go言語】イテレータ
tomo1227
0
70
【Go言語】エラーハンドリング
tomo1227
0
59
AIに淘汰されないようにするには?
tomo1227
0
59
【Go言語】range
tomo1227
0
63
【Go言語】break
tomo1227
0
62
Other Decks in Programming
See All in Programming
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
110
After go func(): Goroutines Through a Beginner’s Eye
97vaibhav
0
400
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
170
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
3.3k
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
非同期jobをtransaction内で 呼ぶなよ!絶対に呼ぶなよ!
alstrocrack
0
950
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
140
Leading Effective Engineering Teams in the AI Era
addyosmani
6
440
開発生産性を上げるための生成AI活用術
starfish719
3
1.1k
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
240
AI Agent 時代的開發者生存指南
eddie
0
1.1k
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
110
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.7k
Practical Orchestrator
shlominoach
190
11k
A better future with KSS
kneath
239
18k
Designing Experiences People Love
moore
142
24k
Done Done
chrislema
185
16k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
35
6.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Producing Creativity
orderedlist
PRO
347
40k
Transcript
Tomoki Ota υϥ🔵ΜͰ%*
υϥ🔵ΜͰDI υϥ🔵ΜͰґଘੑٯసͷݪଇ ΞδΣϯμ
DI
ͷ🟡ଠυϥ🔵Μʹґଘ ͷ🟡ଠυϥ🔵Μͷ͜ͱΛ ୭ʹ૬ஊ͠ͳ͍ͷͰɺ୭ υϥ͑Μ͕ؔΘ͍ͬͯΔ͜ ͱΛΓ·ͤΜɻ ґଘੑͷೖ ʙDI͍ͯ͠ͳ͍ঢ়ଶʙ
ͷ🟡ଠυϥ🔵Μʹґଘ ͷ🟡ଠυϥ🔵Μͷ͜ͱΛ ଞͷਓʹ૬ஊ͠·ͨ͠ɻ ґଘੑͷೖ ʙDIͨ͠ঢ়ଶʙ ೖͱݺͿ
໌ࣔతʹपΓʹԿΛඞཁͱ͢Δ͔ એݴ͢Δ͜ͱ ڱٛͷDI
ٛͷDI ґଘੑͷೖɺϦείϑͷஔݪଇɺAdatpterύλʔϯɺ CompositeύλʔϯͳͲ͋ΒΏΔύλʔϯͷू·Γɻ ίʔυΛૄ݁߹ʹͯ͠ɺอक༰қੑΛ্ͤ͞Δ
DI͔ͨ͠Βґଘੑͳ͘ͳΔ → ґଘੑແ͘ͳΓ·ͤΜ Α͋͘Δޡղ
DI͔ͨ͠ΒςετͰϞοΫͰ͖Δ → Ͱ͖Δ߹ͱͰ͖ͳ͍߹͕͋Δ Α͋͘Δޡղ
ςετͰ͖Δྫ ೖ
ςετͰ͖Δྫ ӈͷςετ
ςετͰ͖ͳ͍ྫ
DIͱςετ நతͳͷʹґଘ͍ͯ͠ΕɺDIͨ͠ ͚ͩͰςετͰ͖Δɻ ۩ମʹґଘ͍ͯ͠Δ߹ɺDIͯ͠ς ετͰ͖ͳ͍ɻ
ґଘੑٯసͷݪଇ
ґଘੑٯస ʙٯస͍ͯ͠ͳ͍ঢ়ଶʙ υϥ🔵Μ͕ͷ🟡ଠʹґଘ
ґଘੑٯస υϥ🔵Μͱͷ🟡ଠ͕ɺ࢛࣍⚪ϙέοτʹґଘ
ґଘੑٯస υϥ🔵Μ͕ɺͷ🟡ଠ(ͷ🟡ଠͱ࢛࣍⚪ϙέοτ)ʹґଘ ʙٯసͨ͠ঢ়ଶʙ
ґଘੑͷೖ ࢛࣍⚪ϙέοτ͑͋͞Εɺυ🟠ϛͰ͍͍
·ͱΊ ۩ମ͔Βநґଘͤ͞Δ͜ͱͰɺґଘੑΛ ٯస͢Δ͜ͱ͕Ͱ͖Δɻ → ςετ͕͘͢͠ͳΔ → Γସ͕͑͘͢͠ͳΔ