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
IoC-DI-DIContainer
Search
nozawa
December 27, 2024
Technology
0
5
IoC-DI-DIContainer
自分のIoCとDI、DIコンテナの理解力を確かめるべく、後輩に説明するシチュエーションを想定して
作ってみた資料です。
nozawa
December 27, 2024
Tweet
Share
More Decks by nozawa
See All by nozawa
cool-URI-dont-change
yuunozawa
2
6
about-script-language
yuunozawa
2
5
ansible-demo
yuunozawa
2
9
ansible-learning
yuunozawa
2
3
event-loop
yuunozawa
2
3
DDD-4layers
yuunozawa
2
15
AWS-cloud-practitioner
yuunozawa
2
3
Other Decks in Technology
See All in Technology
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
130
podman_update_2024-12
orimanabu
1
300
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
400
プロダクト組織で取り組むアドベントカレンダー/Advent Calendar in Product Teams
mixplace
0
360
生成AIのガバナンスの全体像と現実解
fnifni
1
230
ソフトウェア開発における「パーフェクトな意思決定」/Perfect Decision-Making in Software Development
yayoi_dd
1
1.9k
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
3
730
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
2
680
3年でバックエンドエンジニアが5倍に増えても破綻しなかったアーキテクチャ そして、これから / Software architecture that scales even with a 5x increase in backend engineers in 3 years
euglena1215
11
3.9k
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
300
大規模言語モデルとそのソフトウェア開発に向けた応用 (2024年版)
kazato
1
110
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
190
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Become a Pro
speakerdeck
PRO
26
5k
Building Applications with DynamoDB
mza
91
6.1k
The Pragmatic Product Professional
lauravandoore
32
6.3k
BBQ
matthewcrist
85
9.4k
Mobile First: as difficult as doing things right
swwweet
222
9k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Side Projects
sachag
452
42k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Code Reviewing Like a Champion
maltzj
521
39k
Transcript
ᖒ *P$ͱ%*ɺ%*ίϯςφΛઆ໌͢Δ ษڧձ༻
*P$ͱԿ͔ ֓ཁ w *OWFSTJPOPG$POUSPM ੍ޚͷస ͷ͜ͱ w ʮґଘؔΛٯసͤ͞Δʯ͜ͱΛࢦ͢ *P$*OWFSTJPOPG$POUSPMͷུͰ͢ɻ ຊޠʹ༁ͯ͠ʮ੍ޚͷసʯͱͳΓɺཧղ͠ʹ͍͘··Ͱ͢ɻ
͜͜ͰʮґଘؔΛٯసͤ͞Δʯ͜ͱΛࢦ͢ͱཧղ͍͚ͨͩΕͱࢥ͍·͢ɻ ͰʮґଘʯͱԿͰ͠ΐ͏͔ɻʮґଘʯ͕͔ΕࣗͣͱͦΕΛʮٯసͤ͞Δʯͱ͍͏ҙຯ͕͔ͬͯ͘Δͱࢥ͍·͢ɻ ͜ͷൃදͰαϯϓϧίʔυΛݩʹ·ͣʮґଘʯʹ͍ͭͯཧղ͢Δ͜ͱΛࢦ͠·͢ɻ
*P$ͱԿ͔ -JHIU#VMC ిٿ Λ4XJUDIͰૢ࡞͢Δαϯϓϧίʔυ QVCMJDDMBTT-JHIU#VMC\ QVCMJDWPJEPO \ TZTUFNPVUQSJOUMO lޫΓ·͢z
^ QVCMJDWPJEP ff \ TZTUFNPVUQSJOUMO lফ͑·͢z ^ ^ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU#VMCCVMCOFX-JHIU#VMC WPJEUVSO0O \ CVMCPO ^ WPJEUVSO0 ff \ CVMCP ff ^ ^ ʮґଘʯΛཧղ͢ΔͨΊͷαϯϓϧίʔυ͕ͪ͜ΒͰ͢ɻ αϯϓϧίʔυͰೋͭͷΫϥε͕ొ͠·͢ɻ Ұͭ-JHIU#VMCʢిٿʣΫϥεͰ͢ɻ -JHIU#VMCΫϥεೋͭϝιουΛ࣋ͪ·͢ɻ ిؾ͕͍ͭͨঢ়ଶΛද͢POϝιουͱফ͑ͨঢ়ଶΛද͢P ff ϝιουͰ͢ɻ ͏Ұͭ4XJUDIΫϥεͰ͢ɻిؾͷεΠονͷ͜ͱͰ͢ɻ ిؾΛΧνΧνͱ0/0''͢ΔͨΊͷUVSO0OϝιουͱUVSO0 ff ϝιουΛ͍࣋ͬͯ·͢ɻ 4XJUDIΫϥεͷϝϯόఆٛΛݟ͍ͯͩ͘͞ɻ -JHIU#VMCΫϥεΛΠϯελϯεԽͯ͠ϝϯόͱͯ͠อ༗͍ͯ͠·͢ɻ ·ͨɺఆٛ͞ΕͨϝϯόUVSO0O UVSO0 ff ϝιουͰ༻͞Ε͍ͯ·͢ɻ ͜ͷ࣮4XJUDIΫϥε͔Β-JHIU#VMCΫϥεͷґଘΛද͍ͯ͠·͢ɻ UVSO0O UVSO0 ff ϝιουͰ-JHIU#VMCΠϯελϯεΛ༻ͯ͠ɺPO P ff ϝιουΛ࣮ߦ͠Α͏ͱ͍ͯ͠·͢ͷͰɺ-JHIU#VMCΠϯελϯε͕ଘࡏ͠ͳ͍ɺ͘͠ -JHIU#VMCΠϯελϯε͡Όͳ͚ΕిؾΛΧνΧνͱ0/0''͢Δ͜ͱ͕Ͱ͖·ͤΜɻ ʮͳ͍ͱͩΊʯͳͷͰʮґଘ͍ͯ͠Δʯͱݴ͑·͢ɻ
ɿΫϥεؒͷґଘ͕ڧ͍ ͜ͷεΠονిٿҎ֎ͷ ໌͔ΓΛ͚ͭΒΕͳ͍ ෆศ ͋ΔΫϥεಉ͕࢜ґଘঢ়ଶʹ͋Δͱ͕ى͜Δ͜ͱ͕͋Γ·͢ɻ ྫ͑͜ͷྫͰεΠονిٿͷͨΊʹઃܭ͞Ε͍ͯΔͷͰɺ͠ܬޫ౮ͷిؾΛ͚͍ͭͨ߹ɺ͜ͷεΠονʹཱͨͳ͘ͳͬͯ͠·͍·͢ɻ ͜ͷαϯϓϧͷΑ͏ͳΫϥεؒͷؔΛࢦͯ͠ʮ͋ΔΫϥε"͕͋ΔΫϥε#ʹґଘ͍ͯ͠ΔʯͷΑ͏ʹݴ͍·͢ɻ͜ͷαϯϓϧͷέʔεͰʮ4XJUDIΫϥε͕ -JHIU#VMCΫϥεʹڧΊʹґଘ͍ͯ͠Δʯͱݴ͑·͢ɻ·ͨɺʮґଘੑ͕ڧ͍ͱมߋʹऑ͍ʯͱݴ͑ͦ͏Ͱ͢ɻ ͏͠Β͘ɺ͜ͷαϯϓϧϓϩάϥϜʹ͓͖߹͍͍ͩ͘͞ɻ ଓ͍ͯͷઆ໌Ͱɺ4XJUDIΫϥεΛ৭ʑͳর໌ث۩ʹରԠͰ͖ΔΑ͏ʹมߋʹڧͯ͘͠Έ·͢ɻ
*P$ͱԿ͔ -JHIU4PVSDF ԿΒ͔ͷর໌ث۩ Λ4XJUDIͰૢ࡞͢Δαϯϓϧίʔυ QVCMJDJOUFSGBDF-JHIU4PVSDF\ WPJEPO WPJEP ff
^ ࣍ͷεϥΠυʹίʔυ͕ଓ͖·͢ ͔͜͜ΒͷαϯϓϧίʔυͰɺҰͭΫϥε͕૿͑ɺͭͷΫϥε͕ొ͠·͢ɻ ͏ͪೋͭઌ΄Ͳͱಉ͡Ͱ͕͢ɺͭͷมߋͱͯ͠ɺ*OUFGBDF͕Ճ͞Ε·ͨ͠ɻ ͜ͷΠϯλʔϑΣʔεԿΒ͔ͷর໌ث۩Λࢦ͍ͯ͠ΔͷͰɺ-JHIU4PVSDFͱݺͼ·͢ɻ -JHIU4PVSDFΠϯλʔϑΣʔεPOͱP ff ͱ͍͏ೋͭͷϝιουΛ࣋ͪ·͢ɻ ͜Ε*OUFSGBDFͳͷͰɺϝιουએݴͷΈ͞Ε͓ͯΓɺநతʹͳ͍ͬͯ·͢ɻ
*P$ͱԿ͔ -JHIU4PVSDF ԿΒ͔ͷর໌ث۩ Λ4XJUDIͰૢ࡞͢Δαϯϓϧίʔυ QVCMJDDMBTT-JHIU#VMCJNQMFNFOUT-JHIU4PVSDF\ !0WFSSJEF QVCMJDWPJEPO \ TZTUFNPVUQSJOUMO lޫΓ·͢z
^ !0WFSSJEF QVCMJDWPJEP ff \ TZTUFNPVUQSJOUMO lফ͑·͢z ^ ^ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU4PVSDFMJHIU4PVSDF QVCMJD4XJUI -JHIU4PVSDFMJHIU4PVSDF \ UIJTMJHIU4PVSDFMJHIU4PVSDF ^ WPJEUVSO0O \ MJHIU4PVSDFPO ^ WPJEUVSO0 ff \ MJHIU4PVSDFP ff ^ ^ ଓ͍ͯɺ-JHIU#VMCΫϥε͕-JHIU4PVSDFΠϯλʔϑΣʔεΛJNQMFNFOUT ࣮ ͢ΔΑ͏ʹͳ͍ͬͯ·͢ɻ ͜ΕʹΑΓʮর໌ث۩ͷ࣮ͱͯ͠ͷిٿʯͱ͍͏ҙຯ߹͍ʹͳΓ·͢ɻ -JHIU#VMCΫϥεͷมߋ͜Ε͚ͩͰ͢ɻ ࠷ޙʹ4XJUDIΫϥεͷมߋͰ͢ɻ ·ͣϝϯόͷܕ͕-JHIU#VMCΫϥεͰͳ͘-JHIU4PVSDFΠϯλʔϑΣʔεʹͳ͍ͬͯ·͢ɻ -JHIU4PVSDFΠϯλʔϑΣʔεԿΒ͔ͷর໌ث۩Λࢦ͍ͯ͠·͢ɻ ઌ΄Ͳ͜ͷϝϯόͷఆٛͰґଘઌ͕-JHIU#VMCΫϥεʹఆ·͍ͬͯ·ͨ͠ɻ ݱࡏ-JHIU4PVSDFΠϯλʔϑΣʔεʹͳ͍ͬͯΔͨΊɺ-JHIU4PVSDFΠϯλʔϑΣʔεΛJNQMFNFOUT͍ͯ͠ΔΫϥεͷΦϒδΣΫτશͯ͜ͷܕͷมʹೖͰ͖· ͢ɻ ͦͯ͠࠷ॏཁͳมߋͱͯ͠ίϯετϥΫλ͕Ճ͞Ε͍ͯ·͢ɻ ίϯετϥΫλ෦Ͱࣗͷ-JHIU4PVSDFܕͷϝϯόΛઃఆ͍ͯ͠·͢ɻ ݴ͍͑Δͱɺ-JHIU4PVSDFͷ࣮ΫϥεͷΠϯελϯεΛίϯετϥΫλͷݺͼग़͠ݩ͔Βઃఆͯ͠Β͑ΔΑ͏ʹͳ͍ͬͯ·͢ɻ ͜ΕͰɺίϯετϥΫλ͔Β͖ͳর໌ث۩Λͯ͠Β͑Εͦͷর໌ث۩ͷૢ࡞͕Ͱ͖Δ ॊೈͳεΠον͕ग़དྷ্͕Γ·ͨ͠ɻ
*P$ͱԿ͔ ͭͷαϯϓϧίʔυͷҧ͍Λ·ͱΊΔͱ มߋɿ *OUFSGBDFΛՃ -JHIU#VMCΫϥε͕*OUFSGBDFΛ࣮ 4XJUDI͕ґଘઌͷΦϒδΣΫτΛݺͼग़͠ݩ͔Βઃఆͯ͠Β͍ͬͯΔ Կ͕ྑ͘ͳ͔ͬͨɿΫϥεؒͷґଘ͕ऑ͘ͳΓมߋʹڧ͘ͳͬͨ
͜͜·Ͱͷ·ͱΊΛ͠·͢ɻ ͜͜·ͰͰʮґଘʯͱԿ͔ʹ͍ͭͯઆ໌͖ͯ͠·ͨ͠ɻ αϯϓϧίʔυͷൺֱΛ௨ͯ͠ʮґଘੑ͕ߴ͍ʯྫͱʮґଘੑ͕͘ͳͬͨʯྫΛ͓ݟͤ͠·ͨ͠ɻ ྫΛ௨͠ɺґଘੑ͕ߴ͍͔͍͔Ͱมߋͷڧ͕͞มΘΔ͜ͱΛ͝આ໌͠·ͨ͠ɻ Ͳ͏ͯ͠ґଘੑ͕Լ͕͔ͬͨεϥΠυʮมߋʯʹهࡌͷ༰Λ࣮ࢪͨͨ͠ΊͰ͋Γɺ ॏཁͳґଘઌΛ֎෦͔Βઃఆ͢ΔΑ͏ʹͨ͜͠ͱͰ͢ɻ ґଘ͕͔ͬͨͱ͜ΖͰ͏Ұ*P$͕ԿͰ͔͋ͬͨ֬ೝ͍͖͍ͯͨ͠ͱࢥ͍·͢ɻ
*P$ͱԿ͔ ·ͱΊ w *OWFSTJPOPG$POUSPM ੍ޚͷస ͷ͜ͱ w ʮґଘؔΛٯసͤ͞Δʯ͜ͱΛࢦ͢ 74 4XJUDIΫϥε͕ґଘઌΛܾΊΔ
4XJUDIΫϥεґଘઌΛܾΊͳ͍ ݺͼग़͠ଆʹܾΊͤ͞Δ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU#VMCCVMCOFX-JHIU#VMC WPJEUVSO0O \ CVMCPO ^ WPJEUVSO0 ff \ CVMCP ff ^ ^ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU4PVSDFMJHIU4PVSDF QVCMJD4XJUI -JHIU4PVSDFMJHIU4PVSDF \ UIJTMJHIU4PVSDFMJHIU4PVSDF ^ WPJEUVSO0O \ MJHIU4PVSDFPO ^ WPJEUVSO0 ff \ MJHIU4PVSDFP ff ^ ^ ಄Ͱ*P$ͱʮґଘؔΛٯసͤ͞Δʯ͜ͱΛࢦ͢ͷͰ͋Δͱ͓͑͠·ͨ͠ɻ ઌ΄Ͳͷαϯϓϧιʔεͷ4XJUDIΫϥεΛࢥ͍ग़͍ͯͩ͘͠͞ɻ ݩʑɺ-JHIU#VMCܕͷมΛϝϯόͱͯ࣋ͭ͜͠ͱͰɺґଘઌΛ4XJUDIΫϥε͕ܾࣗΊ͍ͯ·͕ͨ͠ɺ มߋʹڧ͍ίʔυʹͨ͠ޙɺ4XJUDIΫϥεґଘઌΛݺͼग़͠ݩʹܾΊͯΒ͏Α͏ʹͳΓ·ͨ͠ɻ ґଘઌ͕ܾ·Δ࣌ͷ͖͕ٯʹͳΔײ͕͡Θ͔Γ·͢Ͱ͠ΐ͏͔ʁ
*P$ͱԿ͔ ґଘؔͷٯసΛࢹ֮తʹ͢Δͱ 4XJUDIΫϥεΛ ΠϯελϯεԽ͢ΔԿ͔ QVCMJDDMBTT-JHIU#VMC\ QVCMJDWPJEPO \ TZTUFNPVUQSJOUMO lޫΓ·͢z
^ QVCMJDWPJEP ff \ TZTUFNPVUQSJOUMO lফ͑·͢z ^ ^ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU#VMCCVMCOFX-JHIU#VMC WPJEUVSO0O \ CVMCPO ^ WPJEUVSO0 ff \ CVMCP ff ^ ^ QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU4PVSDFMJHIU4PVSDF QVCMJD4XJUI -JHIU4PVSDFMJHIU4PVSDF \ UIJTMJHIU4PVSDFMJHIU4PVSDF ^ WPJEUVSO0O \ MJHIU4PVSDFPO ^ WPJEUVSO0 ff \ MJHIU4PVSDFP ff ^ ^ ґଘੑͷ͖Λࢹ֮తʹҹͰදݱͯ͠͝આ໌͠·͢ɻ *P$ΛऔΓೖΕ͍ͯͳ͍ɺ࠷ॳͷαϯϓϧιʔεͰґଘઌΛ4XJUDIΫϥε͕ܾࣗΊ͍ͯ·ͨ͠ɻ4XJUDIΫϥε͕ґଘઌΛܾΊ͍ͯΔͷͰҹґଘઌͷ-JHIU#VMCΫ ϥεʹ৳ͼ·͢ɻ Ұํɺ*P$ΛऔΓೖΕͨαϯϓϧιʔεͰɺ4XJUDIΫϥεͷґଘઌʮ4XJUDIΫϥεΛΠϯελϯεԽ͢ΔԿ͔ʯʹܾΊͯΒ͍ͬͯ·͢ɻʮԿ͔ʯͱ͍͏ͷίϯε τϥΫλͰɺΠϯελϯεϝιουͰɺ.BJOؔͰԿͰΑ͍ͱ͍͏ҙຯͰ͢ɻ4XJUDIΫϥε͕ґଘઌΛܾΊͯΒ͍ͬͯΔΠϝʔδͰ͢ͷͰɺҹٯʹͳΓ ·ͨ͠ɻ ґଘͷ͖Λද͢ҹ͕ٯʹͳͬͨͷͰɺʮґଘ͕ؔٯసͨ͠ʯͱ͍͑·͢ɻ ͜Ε͕*P$Ͱ͢ɻ
QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU4PVSDFMJHIU4PVSDF QVCMJD4XJUI -JHIU4PVSDFMJHIU4PVSDF \ UIJTMJHIU4PVSDFMJHIU4PVSDF ^ WPJEUVSO0O \
MJHIU4PVSDFPO ^ WPJEUVSO0 ff \ MJHIU4PVSDFP ff ^ ^ %*ͱԿ͔ w %FQFOEFODZ*OKFDUJPO ґଘੑͷೖ ͷ͜ͱ w ͋ΔΫϥεͷ۩ମతͳʮґଘੑͷೖϝΧχζϜʯͷ͜ͱΛࢦ͢ *P$ͷԆͰཧղͰ͖Δ *P$ΛཧղͰ͖͍ͯΕɺ%*ʹ͍ͭͯͷཧղൺֱత؆୯ʹͳΓ·͢ɻ %*ຊޠʹ͢ͱʮґଘੑͷೖʯͰ͢ɻ *P$ΛऔΓೖΕͨ4XJUDIΫϥεΛ࠶ར༻͠·͢ɻ 4XJUDIΫϥεͷίϯετϥΫλͰ͕͢ɺ*P$ͷ࣮ફʹΑΓґଘઌͷ-JHIU4PVSDFΦϒδΣΫτΛίϯετϥΫλΛ௨ͯ͠ݺͼग़͠ݩ͔Βઃఆͯ͠Β͑ΔΑ͏ʹ ͳ͍ͬͯ·͢ɻ ͜ͷɺʮґଘੑΛ֎෦͔Βೖ͢Δ͜ͱʯΛ%*ͱݴ͍·͢ɻ %*ʹछྨ͕͋Γɺ࣮ํ๏छྨʹΑͬͯҟͳΓ·͢ɻ εϥΠυͷ%*ίϯετϥΫλΛ͏ͷͰʮίϯετϥΫλΠϯδΣΫγϣϯʯͱݴ͍·͢ɻଞʹ4FUUFSϝιου͔ΒґଘੑΛೖͤ͞ΔʮηολʔΠϯδΣΫγϣ ϯʯͳͲ͕͋Γ·͢ɻ
%*ͱԿ͔ ґଘੑͷೖΛࢹ֮తʹ͢Δͱ 4XJUDIΫϥεΛ ΠϯελϯεԽ͢ΔԿ͔ %* QVCMJDDMBTT4XJUDI\ QSJWBUF-JHIU4PVSDFMJHIU4PVSDF QVCMJD4XJUI -JHIU4PVSDFMJHIU4PVSDF
\ UIJTMJHIU4PVSDFMJHIU4PVSDF ^ WPJEUVSO0O \ MJHIU4PVSDFPO ^ WPJEUVSO0 ff \ MJHIU4PVSDFP ff ^ ^ *P$ͷઆ໌ͰͬͨਤΛ࠶༻͢Δͱɺҹͷ෦͕%*ͱͳΓ·͢ɻ
%*ίϯςφͱԿ͔ %*ͷԆͰཧղͰ͖Δ w Ϋϥεಉ࢜ͷґଘؔΛࣗಈతʹղܾ͢Δͷ w %*ίϯςφͲͷΫϥε͕ͲͷΫϥεʹґଘ͢Δ͔ղੳ͢Δ w %*ίϯςφ*P$ͱ%*ͷݪଇΛ࣮ݱ͢ΔͨΊͷπʔϧ IUUQTLB[LODPNQPTUJOUSPTQSJOHJPDDPOUBJOFS ࡶଟͳΦϒδΣΫτΛࣗͷཧԼʹ
ஔ͖ͦΕΒΛڠௐͤ͞ΔΦϒδΣΫτ ίϯςφ %*·ͰཧղͰ͖ͨͱ͜ΖͰ%*ίϯςφͷઆ໌Λ؆୯ʹ͠·͢ɻ %*ʹʮίϯςφʯͱ͍͏ݴ༿͕͖ͬͭ͘·ͨ͠ɻ 4FSWMFUίϯςφͱ͔ɺ&+#ίϯςφͱ͔ɺͷ+BWBք۾ͰԿ͔ͱʮίϯςφʯͱ͚͍ͭͯͨͱɺ͋ΔهࣄͰհ͍ͯ͠·ͨ͠ɻ ͦͷهࣄͷݴ༿ΛआΓͯɺ͜͜ͰʮίϯςφʯʮࡶଟͳΦϒδΣΫτΛࣗͷཧԼʹஔ͖ͦΕΒΛڠௐͤ͞ΔΦϒδΣΫτʯͱ͠·͢ɻ ίϯςφΛ͜͏ଊ͑Δͱɺʮ%*ίϯςφʯʮΫϥεಉ࢜ͷґଘؔΛࣗಈతʹղܾ͢Δͷʯͱ͍͏Πϝʔδʹͳ͖ͬͯ·͢Ͱ͠ΐ͏͔ʁ Ҏ্Ͱ*P$ɺ%*ɺ%*ίϯςφʹ͍ͭͯͷઆ໌ΛऴΘΓ·͢ɻ