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
DDD-4layers
Search
nozawa
December 22, 2024
Programming
2
15
DDD-4layers
ジャンケンアドカレを読んでDDD×4層に入門したので、
ありがちな悪いアーキテクチャと比較しながら理解をアウトプットしました。
nozawa
December 22, 2024
Tweet
Share
More Decks by nozawa
See All by nozawa
IoC-DI-DIContainer
yuunozawa
0
3
cool-URI-dont-change
yuunozawa
2
6
about-script-language
yuunozawa
2
4
ansible-demo
yuunozawa
2
9
ansible-learning
yuunozawa
2
3
event-loop
yuunozawa
2
3
AWS-cloud-practitioner
yuunozawa
2
3
Other Decks in Programming
See All in Programming
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
130
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
350
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
1k
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
100
MCP with Cloudflare Workers
yusukebe
2
230
선언형 UI에서의 상태관리
l2hyunwoo
0
200
快速入門可觀測性
blueswen
0
420
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
540
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
290
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
190
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Producing Creativity
orderedlist
PRO
342
39k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
530
RailsConf 2023
tenderlove
29
940
How to train your dragon (web standard)
notwaldorf
88
5.7k
Become a Pro
speakerdeck
PRO
26
5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Statistics for Hackers
jakevdp
796
220k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Optimizing for Happiness
mojombo
376
70k
Transcript
ᖒ %%%✖ͷৼΓฦΓ ษڧձ༻
%%%✖ͷৼΓฦΓ wֶशͷ͖͔͚ͬ Ϟνϕʔγϣϯ wͳͥ%%%✖ΛબͿͷ͔ w࣮ફͯ͠Έͯͷॴײ
͖͔͚ͬ ݁ɿδϟϯέϯΞυΧϨΛಡΈɺͩΒ͚ͳΞʔΩςΫνϟͷվળʹ׆͔ͤΔͱࢥͬͨ IUUQTRJJUBDPNBEWFOUDBMFOEBSKBOLFO
ҙࣝᶃΞʔΩςΫνϟ w 4QSJOHGSBNFXPSL .7$ τϥϯβΫγϣϯεΫϦϓτ w ϨΠϠʔ͕શ͔͘Βͳ͍ Αͬͯɺґଘͷ͖͕ཧ͞Εͳ͍
w ೝෛՙ͕ߴ͍ ΞʔΩςΫνϟ͕͋ΔΑ͏Ͱͳ͍ͨΊ࡞ΓΛ ΔͨΊʹ࣮Λ͏͔͠ͳ͍ ͖͔͚ͬ TSDNBJOKBWB cDPOUSPMMFS cFOUJUZ cTFSWJDF cGPSN cSFQPTJUPSZ cNPEFM cFYDFQUJPO cʜ TSDNBJOXFC cQBHFTը໘ cʜ
ҙࣝᶄ4FSWJDF w υϝΠϯ͕ࣝ݁ू͍ͯ͠Δ ӬଓԽͷ੍ɺϧʔϧ͜͜ w ࠷Մಡੑ͕͍ ಛʹ%50ͷॲཧͪΐͬͱͨ͠6*ͷؔ৺͝ͱͰ ͳͷʹΫϥεͷେΛΊ͍ͯͨΓ͢Δ w ෳࡶੑͱͬͱઓ͑Δͱײ͡Δ
͖͔͚ͬ !4FSWJDF QVCMJDDMBTT4FSWJDF\ !"VUPXJSFE QSJWBUF0UIFS4FSWJDFPUIFS4FSWJDF !"VUPXJSFE QSJWBUF3FQPTJUPSZSFQPTJUPSZ QVCMJD'PSNTFU'PSN%BUF 'PSNGPSN \ GPSNTFU.PEFM SFQPTJUPSZHFU%BUB#Z*E GPSNHFU*E ݸผͰ6*߹ͷͭΊͭΊ GPSNTFU*UFN SFUVSOGPSN ^ QVCMJD'PSNJOTFSU 'PSNGPSN \ JOTFSU༻ͷFOUJUZ ʹͭΊͭΊ .PEFMNPEFMOFX.PEFM JEͷ࠾൪͜͜Ͱ͢Δ NPEFMTFU*E SFQPTJUPSZHFU/FYU*E ^ ^
ҙࣝᶅ&OUJUZ .PEFM w ςʔϒϧσʔλήʔτΣΠ 3%#ͷςʔϒϧͱରɻ&OUJUZग़ྗ͘Μతͳ&YDFMϚ Ϋϩ͕͋ͬͨΓ͢Δ w +0*/ͷଟ͍ෳࡶͳΫΤϦ.PEFMΛ ͏ ςʔϒϧσʔλήʔτΣΠͷฐͩͱࢥ͏ɻ001త
Ͱͳ͘ઃܭΛݟ͑ʹ͘͘͢ΔݪҼͩͱݸਓతʹࢥͬ ͍ͯΔ w &OUJUZͱ.PEFM͕ͨ͘͞Μ͋Δ ςʔϒϧ ΧϥϜͷ6*දࣔͷͨΊʹ&OUJUZΛܧঝͯ͠ ࠩͷΧϥϜͨ͠.PEFM͕࡞ΒΕ͍ͯΔ͜ͱ͕ཧ ༝ͩͱࢥ͍ͬͯΔ ͖͔͚ͬ !&OUJUZ QVCMJDDMBTTB5CMJNQMFNFOUT4FSJBMJ[BCMF\ !*E !$PMVNO OBNFlJEz QSJWBUFMPOHJE ҎԼɺશϑΟʔϧυʹର͢Δ4FUUFS (FUUFS QVCMJDMPOHHFU*E \ SFUVSOJE ^ QVCMJDWPJETFU*E MPOHJE \ UIJTJEJE ^ ^
ҙࣝᶆ3FQPTJUPSZ w ΦϨΦϨ+%#$ϥούʔ w σʔλࢦΦϒδΣΫτࢦ &OUJUZର3FQPTJUPSZ w υϝΠϯ͕ࣝ࿙Εग़͍ͯΔ VQEBUFʓʓͰݸผΞοϓσʔτͨ͠Γෳࡶͳ༷ Λෳࡶͳ42-Ͱؤுͬͯղܾ͢ΔͳͲ
w SFQPTJUPSZ ӬଓԽͷӅṭ Ͱͳ͍ Α͏ͳ 42-ϑΝΠϧΛಡΜͰ͍Δ͠Լखͨ͠Β42-Λ ॻ͍͍ͯΔɻ%"0ύλʔϯ ͖͔͚ͬ !3FQPTJUPSZ QVCMJDDMBTT3FQPTJUPSZ\ !"VUPXJSFE QSJWBUF+ECD.BOBHFSKECD.BOBHFS QVCMJD-JTU.PEFMHFU)PHF#Z*E .PEFMN \ SFUVSOKECD.BOBHFSHFU3FTVMU CFBODMBTT lTRMQBUIz N ^ QVCMJDJOUJOTFSU .PEFMN \ SFUVSOKECD.BOBHFSJOTFSU lTRMQBUIz N ^ ^
͖͔͚ͬ·ͱΊ w ϨΠϠʔ͝ͱͷ࠴ͱґଘΛ͖ͬΓͤͯ͞ೝతෛՙΛ͍ͨ͘͠ w Ϋϥε͝ͱͷ࠴Λ͖ͬΓ͍ͤͨ͞ FOUJUZͰ͍͔ۤ͠ΒNPEFM͏ͱ͔ݏ w ͬͱΦϒδΣΫτࢦΛಥ͖٧Ί͍ͨ ݸਓతཉٻ
w ͰͲ͏ͬͯίʔυʹམͱ͍͍ͤͷʁ ɹɹ ɹɹ͡ΌΜ͚ΜΞυϕϯτΧϨϯμʔʹग़ձ͍ ɹɹܰྔ%%%ͱ ϨΠϠʔυΞʔΩςΫνϟ ͕ྑͦ͞͏ͩͱؾͮ͘ IUUQTRJJUBDPNBEWFOUDBMFOEBSKBOLFO
ͳͥ%%%✖͔ ݁ɿδϟϯέϯΞυΧϨͱদԬ͞ΜʹΑΔೖํ๏Λ৴པ͍ͯ͠Δ͔Β
ͳͥ%%%✖͔ w ʮ%%%ઓུతઃܭͱઓज़తઃܭ͕͋ΔΑ͏ͩʯ w ʮઓུతઃܭυϝΠϯΤΩεύʔτͱͷର͕ॏཁͰݸਓͰݶք͕͋Δͳʯ w ʮઓज़తઃܭ͚ͩؤுΔܰྔ%%%ΞϯνύλʔϯͬͯݴΘΕΔͷ͔ʯ w ʮΞϯνύλʔϯͳΒΔҙຯͳ͍ͷͰʁʯ
দԬ͞Μl%%%ͷϞ デ Ϧϯ グ ͱԿͳͷ͔ɺͦͯ͠ ど ͏ίʔ ド ʹམͱ͢ͷ͔z w ΈΜͳܰྔ%%%Ͱ࢝Ί͍ͯΔʂ
ͳͥ%%%✖͔ w ʮܰྔ%%%Ͱ࢝Ί͍͍ͯΒ͍͠ɺͰΞʔΩςΫνϟຊʹͰ͍͍ͷ͔ ʯ দԬ͞Μl৽ଔʹΘΔυϝΠϯۦಈઃܭͷΞʔΩςΫνϟઆ໌z ̐%%%ೖʹྑͦ͞͏
ॴײ ݁ɿʮΞʔΩςΫνϟτϨʔυΦϑͰ͋ΔʯΛ࣮ײͨ͠
ྑ͍ͱײ͡Δ໘ w ύοͱݟͯͱΘ͔Δ͜ͱͰೝ ෛՙԼ͕ͬͨͱࢥ͏ w ϨΠϠʔ͝ͱʹ4FSWJDFΛׂͰ ͖ͨ w 4FSWJDF&YDFQUJPOΛͰΓ ͚ͯߟ͑ΒΕΔΑ͏ʹͳͬͨ
ྫ͑SFRVFTUQBSBNTʹର͢Δྫ֎ "QQMJDBUJPOɺυϝΠϯͷ੍্ͷྫ֎ EPNBJOɺͳͲ ॴײ ΞʔΩςΫνϟฤ TSDNBJOKBWB cBQQMJDBUJPOTFSWJDF cEPNBJO cNPEFM cTFSWJDF cFYDFQUJPO cJOGSBTUSVDUVSF cSFQPTJUPSZ cQSFTFOUBUJPO cFYDFQUJPO cBQJ cEUP
ѱ͍ͱײ͡Δ໘ ఆ w 4FSWJDFͷ࠴ͷʹΉ ͜Ε%PNBJO4FSWJDF "QQMJDBUJPO4FSWJDF w ϨΠϠʔؒͷσʔλͷड͚͠ ʹΉ
BQQMJDBUJPO4FSWJDFͰQSFTFOUBUJPOͷEUPʹ σʔλΛ٧ΊΔʁґଘͷ͖߹ͬͯΔ ॴײ ΞʔΩςΫνϟฤ TSDNBJOKBWB cBQQMJDBUJPOTFSWJDF cEPNBJO cNPEFM cTFSWJDF cFYDFQUJPO cJOGSBTUSVDUVSF cSFQPTJUPSZ cQSFTFOUBUJPO cFYDFQUJPO cBQJ cEUP
ྑ͍ͱײ͡Δ໘ w &OUJUZ͕ΦϒδΣΫτࢦ͍ͯ͠Δײ FOUJUZͷৼΔ͍ͱͯ͠ఏڙ͞ΕΔϝιου͔Βঢ়ଶ Λมߋ TFUUFSͷ༻ Λ͢Δͷ001ͩͳͱࢥ͏ w &OUJUZΛಡΊ͍͍ͱ͍͏҆৺ײ อकۀʹෳࡶͳΫΤϦͷղಡؚ͕·Ε͍ͯͳ͍͜ͱ
͕อূ͞Ε͍ͯΔ͜ͱਫ਼ਆӴੜ্ྑ͍ w $234ͰNPEFMΫϥε ෳࡶͳ SFQPTJUPSZ͔Βͷղ์ SFQPTJUPSZΛԚ͢ݪҼෳࡶͳRVFSZͰӬଓԽͰͳ ͘6*ͷ߹͔ͩΒׂΓͬͯRVFSZ4FSWJDFΛ࡞Δͱ͍ ͏ߟ͑ํଥੑ͕͋Δͱࢥ͏ ॴײ %%%ฤ @Entity class Task { @Id @GeneratedValue private Long id; private TaskStatus taskStatus; private String name; private int postponeCount; private static final int POSTPONE_MAX_COUNT = 3; /* * ίϯετϥΫλɿ ΤϯςΟςΟ࡞࣌ͷෆม݅Λදݱ */ public Task(String name, LocalDate dueDate) { if (name == null || dueDate == null) { throw new IllegalArgumentException("ඞਢ"); } this.name = name; this.taskStatus = TaskStatus.UNDONE; this.postponeCount = 0; } }
ѱ͍ͱײ͡Δ໘ ఆ w ΠϯϐʔμϯεϛεϚονͷղফ ͕໘͍͘͞ w ूͷΓํ͕%#ͷϞσϦϯά ʹҾͬுΒΕΔ w σʔλΞΫηεͷύϑΥʔϚϯε
ѱͦ͏ ॴײ %%%ฤ !3FQPTJUPSZ QVCMJDDMBTT3FQPTJUPSZ*NQMJNQMFNFOUT3FQPTJUPSZ\ !"VUPXJSFE 1SJWBUF.PPE.BQQFSQPTU.BQQFS QVCMJDWPJETBWF 1PTUQPTU \ QPTU.BQQFSTBWF NPPE -JTU4USJOHJETNPPEHFU.PPE*E TUSFBN fi MUFS MJLF NPPEHFU-JLFT DPOUBJOT MJLF DPMMFDU $PMMFDUPSTUP-JTU -JTU-JLFMJLFTMJLF.BQQFS fi OE#Z*E JET MJLFTGPS&BDI M\ MJLF.BQQFSTBWF M ^ ^ ^
Ҏ্Ͱ͢ ۜͷؙ͕ཉ͍͠