ドメイン駆動設計基礎講座〜戦略編〜

 ドメイン駆動設計基礎講座〜戦略編〜

ChatWork社内勉強会で発表した際の資料

933291444e456bfb511a66a2fa9c6929?s=128

かとじゅん

March 17, 2017
Tweet

Transcript

  1. υϝΠϯۦಈઃܭجૅߨ࠲ ʙઓུฤʙ ͔ͱ͡ΎΜ !KJLP

  2. ਤ΍ه߸ͳͲ΋ग़͖ͯ·͢ɻ ऴ൫ʹίʔυྫ΋͋Γ·͕͢ɺ ৄࡉʹͱΒΘΕΔඞཁ͸͋Γ·ͤΜɻ

  3. υϝΠϯۦಈઃܭ %PNBJO%SJWFO%FTJHO%%%

  4. υϝΠϯͱ͸ʁ z஌ࣝΛ࣋ͪɺӨڹΛ༩͑ɺ ׆ಈ͢ΔྖҬz ιϑτ΢ΣΞ͕ղܾ͢Δ໰୊ ͷྖҬ΍ൣғͷ͜ͱ

  5. ར༻ऀ ୲౰ऀ ຊ୨ ିग़ฦ٫Πϕϯτ ຊ

  6. Ϛοϓ Ϟϯελʔ ෢ث๷۩ ΞΠςϜ ϓϨΠϠʔ ΫΤετ

  7. ϝοηʔδ Πϕϯτ νϟωϧ άϧʔϓ σόΠε Ϣʔβ

  8. %%%͸ٸਐతͳઃܭख๏ Ͱ͸ͳ͍ എޙʹ͋Δ఻౷తͳ ॻ੶ͨͪʹΑͬͯࢧ͑ΒΕ͍ͯΔ

  9. ':*ΦϒδΣΫτࢦ޲ͱ͍͏ߟ͑ํ ߏ੒͢Δ֤֓೦ΛΦϒδΣΫτͱͯ͠ɺιϑτ΢ΣΞʹ൓ө͢ ΔͨΊͷٕज़ɻͦΕͧΕͷΦϒδΣΫτ͸খ͞ͳ໰୊Λղܾ͢ Δɺ͞Βʹ༗ػతʹ࿈ܞͯ͠େ͖ͳ໰୊ղܾΛՄೳͱ͢Δɻ ं γϟʔγ λΠϠ λΠϠ λΠϠ λΠϠ

    Τϯδϯ ϋϯυϧ ϘσΟ ϖμϧ γʔτ ίϯιʔϧ DMBTT$BS CPEZ#PEZ 
 DMBTT#PEZ
 FOHJOF&OHJOF
 DIBTTJT$IBTTJT
 DMBTT$IBTTJT
 GSPOU-FGU5JFS GSPOU3JHIU5JFS
 CBDL-FGU5JFS CBDL3JHIU5JFS
 
 DMBTT&OHJOF DMBTT5JFS
  10. ٸਐతͳઃܭख๏Ͱ͸ͳ͍ w %%%͸ɺΦϒδΣΫτࢦ޲ઃܭͷݪཧओٛΛओு͢ Δઃܭख๏Ͱ΋ɺٸਐతͳઃܭݪཧΛఏএ͢Δ΋ͷͰ ͸ͳ͍ɻ఻౷తͳ͍͔ͭ͘ͷߟ͑ํΛجʹɺڧௐ͢ Δ఺ΛͣΒ͍ͯ͠Δɻ ΤϯδχΞͷࣗݾຬ଍ͷͨΊ ʹ͋Δ΋ͷͰ͸ͳ͍  w

    ίϛϡχέʔγϣϯͱ͜Ε·Ͱͷιϑτ΢ΣΞٕ๏ ʹج͍ͮͨɺυϝΠϯϞσϧ ໰୊Λղ͘ߟ͑ํ Λۦ ࢖ͯ͠ɺυϝΠϯ্ͷ໰୊Λ͍͔ʹղܾ͢Δ͔ͱ͍͏ ఺Λڧௐ͍ͯ͠Δɻ
  11. %%%Λ࣮ફ͢Δҙٛ w Ϗδωεͷઐ໳Ո υϝΠϯΤΩεύʔτ ͱ։ൃऀ ι ϑτ΢ΣΞΤΩεύʔτ Λಉ͡౔ඨʹ৐ͤΔ͜ͱͰɺ ։ൃऀͷࢹ఺͚ͩͰͳ͘Ϗδωεଆͷࢹ఺΋౿·͑ͨ ιϑτ΢ΣΞΛ࡞ΕΔΑ͏ʹ͢Δɻ

    w ͦͷιϑτ΢ΣΞͷ֓೦Λཧղ͍ͯ͠ΔҰ෦ͷਓ ͍ͨ ͍ͯ͸։ൃऀ ͚ͨͪͩͱ͍͏ঢ়گΛͳ͘͢ɻ w υϝΠϯΤΩεύʔτͱ։ൃऀɺιϑτ΢ΣΞͦͷ΋ ͷͱͷؒͰɺҰ੾ͷ௨༁Λෆཁͱ͢Δɻ w ઃܭ͕ίʔυͰ͋Γɺίʔυ͕ઃܭͰ΋͋Δͱ͍͏ঢ় گΛ࡞Γग़͢ɻ Θ͔ΔʂυϝΠϯۦಈઃܭʙ΋ͪ͜ΌΜͷେ๯ݥʙ͔ΒҾ༻
  12. ':*࠷ۙಡΜ͓ͩ͢͢Ίͷຊ Θ͔ΔʂυϝΠϯۦಈઃܭʙ΋ͪ͜ΌΜͷେ๯ݥʙ w %%%ͷઓུΛൺֱ త༰қʹཧղͰ͖ Δຊɻ

  13. ෳࡶ͞ʹͲ͏ཱͪ޲͔͏͔ w ॳظ͸γϯϓϧͰ΋్தͰෳࡶʹͳͬͨ৔߹ ͸པΕΔυϝΠϯϞσϧ͕ͳ͍ͱෳࡶ͞ʹѹ ౗͞Εͯ͠·͏ɻ w υϝΠϯϞσϧʹΑͬͯίϛϡχέʔγϣϯ ͷίΞʹ͢Δ͜ͱɻͦΕ͕ϓϩδΣΫτશମ ʹਁಁͤ͞Δɻձ࿩ɺυΩϡϝϯτɺਤɺΞʔ ΩςΫνϟɻ

  14. υϝΠϯϞσϧͷྫ w νϟοτϧʔϜ͸୭ͷ΋ͷͰ΋ͳ͍ڞ༗෺Ͱ͋Δɻ୭Ͱ΋؅ ཧऀʹͳΕΔՄೳੑ͕͋Δ͕ɺطଘͷ؅ཧऀʹΑͬͯ௥Ճ· ͨ͸ڐՄ͞Εͳ͚Ε͹ͳΒͳ͍ɻ w ڞ༗෺Ͱ͸͋Δ͕ɺ؅ཧऀ͸࠷௿Ͱ΋ਓ͍ͳ͚Ε͹ͳΒͳ ͍ɻ w νϟοτʹࢀՃ͍ͯ͠ΔϢʔβ͸ϝϯόʔͱݺ͹ΕΔɻϝϯ

    όʔͰͳ͍ͱൃݴ͕Ͱ͖ͳ͍ɻ w ؅ཧऀ͸ϝϯόʔΛ௥ՃͰ͖Δɻެ։νϟοτ͸Ϣʔβ͕ࢀ ՃΛਃ੥Ͱ͖ɺ؅ཧऀʹΑͬͯڐՄ͞Εͨ৔߹ʹ ུɻ w ౤ߘ͞Εͨϝοηʔδ͸ɺνϟοτϧʔϜ͕ॴ༗͠ɺϝϯόʔ ͸୭Ͱ΋ಡΉ͜ͱ͕Ͱ͖Δɻ
  15. υϝΠϯϞσϧͷߟ͑ํΛ൓өͨ͠ίʔυ w ͜ͷ͙Β͍ͷந৅౓ͷߴ͍ίʔυ͸ɺίϛϡ χέʔγϣϯͰे෼ʹ࢖͑Δɻ w ͦͷυϝΠϯϞσϧ͕ղܾ͠Α͏ͱ͢Δ໰୊ ͕ු͖ூΓʹͳΔɻͦΕ͸ιϑτ΢ΣΞ͕ղ ܾ͠Α͏ͱ͢Δ໰୊ͱ௚͍݁ͯ͠ͳ͚Ε͹ͳ Βͳ͍ɻ ޿ٛͰ͸ܦӦઓུΛࢧ͑ͳ͚Ε͹ͳ

    Βͳ͍
  16. υϝΠϯϞσϧͷ༗༻ੑ w υϝΠϯϞσϧ ໰୊ʹର͢Δߟ͑ํ ͱઃܭ͸ ڧ͍૬ޓิ׬ؔ܎ʹ͋Δɻ w υϝΠϯϞσϧ͸ར֐ؔ܎ऀશһͰར༻Ͱ͖Δ ڞ௨ݴޠج൫ɻ w

    υϝΠϯϞσϧʹ͸༻ޠͷબ୒΍֓೦ಉ࢜ͷؔ ࿈͔Βબ୒͕͋ΓɺͦΕࣗମ͕໰୊ղܾͷͨΊ ͷઓུΛද͍ͯ͠Δɻ w ίϯλΫτ͸Ϣʔβͷͭͳ͕ΓΛ͕ࣔ͢ɺϑΝ Πϧ΍λεΫͱ͸௚઀ؔ܎͕ͳ͍ͳͲɻ
  17. ιϑτ΢ΣΞͷίΞ w ιϑτ΢ΣΞͷ֩৺͸ɺυϝΠϯʹ͋Δɻ w υϝΠϯ্ͷ໰୊ղܾʹ͸ɺϞσϦϯάεΩϧʹਫ਼௨͢Δ ͜ͱ͕ٻΊΒΕΔɻ͔͠͠ɺҰൠతʹ΄ͱΜͲͷ։ൃऀ͕ ϞσϦϯάεΩϧΑΓٕज़ࢦ޲Ͱ͋Γɺٕज़ͰυϝΠϯ্ ͷ໰୊Λղܾ͢ΔͷͰ͏·͍͔͘ͳ͍ɻ w Ұൠతʹɺ଎͍ͯ҆͘༌ૹۀऀͷίΞͱͳΔυϝΠϯͰ

    ͸ɺٕज़తͳܦ࿏ܭࢉΞϧΰϦζϜ άϥϑΞϧΰϦζϜ ࣗମʹڝ૪ྗͷݯઘͱͳΔՁ஋͕͋ΔΘ͚Ͱ͸ͳ͍ ڝ߹ ΋ಉ͡ΞϧΰϦζϜΛ࢖͏Մೳੑ͕͋ΔͨΊ ɻͦΕΛར ༻ͯ͠༌ૹۀऀͱͯ͠ͷ໨తΛ͍͔ʹୡ੒͢Δ͔ͷํ๏ ͷํ͕Ձ஋͕ߴ͍ɻ w ෳࡶ͞ʹཱͪ޲͔͏ʹ͸ɺυϝΠϯʹ໨Λ޲͚Δ͜ͱɻ
  18. Πϕϯτ ໰୊Λղ͘ߟ͑ํ ʹυϝΠϯϞσϧ "1* */ %# */ "1* 065 %#

    065 ͢΂͕ͯυϝΠϯϞσϧʹΑͬͯۦಈ͢Δߟ͑ํ ར֐ؔ܎ऀ ར֐ؔ܎ऀ
  19. ϞσϦϯάͷࣄ࢝Ί w υϝΠϯʹ͍ͭͯ஌͕ࣝ଍Γͳ͍ͳΒɺ࠷ॳʹ஌ࣝͷ͔ Έࡅ͖͔Β࢝ΊΔɻ஌ࣝͷ͔Έࡅ͖ΛνʔϜͰߦ͏ɻυ ϝΠϯϞσϧʹͦͷϑΟʔυόοΫΛ൓өͰ͖ΔΑ͏ʹ ͢Δɻ w ൓෮ܕϓϩηεͰ͋ͬͯ΋ɺυϝΠϯʹڵຯΛ࣋ͨͳ͚ Ε͹ચ࿅͞ΕͨυϝΠϯϞσϧ͸खʹೖΒͳ͍ɻυϝΠ ϯΤΩεύʔτ

    ղ͘໰୊ʹৄ͍͠ਓɺ։ൃऀͰ΋Α͍ ͱͷڞಉ࡞ۀ͕ඞཁෆՄܽɻ w ͜͏ͨ͠ϓϥΫςΟεʹΑͬͯɺυϝΠϯϞσϧ͕๲େ Ͱෳࡶͳ৘ใΛମܥԽ͢Δπʔϧͱͯ͠ػೳ͢ΔΑ͏ʹ ͳΔ
  20. ஌ࣝΛ͔Έࡅ͘ w 1$#ճ࿏ͷγϛϡϨʔγϣϯπʔϧͷ։ൃɻ w ࠷ॳ͸Կ΋Θ͔Βͳ͔ͬͨɻख࢝Ίʹωοτͱνο ϓͱ͍͏֓೦͕ԿͰ͋ͬͯɺԿͰͳ͍͔Λ೺Ѳͨ͠ɻ

  21. ஌ࣝΛ͔Έࡅ͘ w ͞Βʹ֓೦͕௥Ճ͞Εɺ్தͰ໰୊ղܾʹෆཁͳ΋ ͷ͸࡟আͨ͠ɻձ࿩Λ܁Γฦ͢͜ͱͰɺԿ͕ॏཁͰͦ ͏Ͱͳ͍͔͕Θ͔ΔΑ͏ʹͳΓɺ஌͕͖ࣝͭ࢝Ίͨɻ

  22. ஌ࣝΛ͔Έࡅ͘ w ࠷ऴతʹɺҟৗͳճ࿏Λݟ͚ͭΔͨΊͷɺϗοϓ਺Λ ૊ΈࠐΜͩϞσϧΛखʹೖΕͨɻ

  23. υϝΠϯͷܧଓతֶश w ஌ࣝͷཧղ͸༰қͰ͸ͳ͍ɻҰ౓ಘͨ஌ࣝ΋ྲྀग़ ͢ΔϦεΫ͕͋Δɻੜ࢈తͳνʔϜ͸ɺυϝΠϯʹ ରͯ͠ܧଓతֶशΛ࣮ફ͢Δɻܧଓతʹֶशͨ͠ϝ ϯόʔ͸νʔϜͷίΞͱͳΔɻ w ໨త͸υϝΠϯΤΩεύʔτʹͳΔ͜ͱͰ͸ͳ͘ɺ ॏཁͳ֓೦Λ೺Ѳ͠ɺͦΕΛιϑτ΢ΣΞʹ൓ө ͢Δ͜ͱɻ

    w υϝΠϯΤΩεύʔτ͔ΒϑΟʔυόοΫΛಘͯϓ ϩδΣΫτͷ໨ඪΛ໌֬ʹ͢Δɻ૝ఆ͕֎Εͨͱ͠ ͯ΋ɺ஌ࣝΛ͔Έࡅ͚ΔΑ͏ʹͳΔ͜ͱͰɺνʔ Ϝ͕޷॥؀ͳϑΟʔυόοΫϧʔϓΛճͤΔΑ͏ʹ ͳΔɻ
  24. ஌ࣝ๛෋ͳઃܭ w ֓೦ͷ໊લ͚͕ͩυϝΠϯϞσϧΛ࡞Δࡍͷ ώϯτʹͳΔΘ͚Ͱ͸ͳ͍ɻϏδωε্ͷ੍ ໿Λද͢Α͏ͳϧʔϧͳͲ΋ؚ·ΕΔɻ w ஌ࣝͷ͔Έࡅ͖͸ɺܗࣜతͳઃܭύλʔϯͩ ͚ʹͱͲ·Βͳ͍ɻυϝΠϯΤΩεύʔτ ͱͷ૬ޓ࡞༻ͷதͰ஌ࣝͱͯ͠ݱΕΔ͜ͱ͕ ͋Δɻ

  25. ΦʔόʔϒοΩϯάͷ࿩ w ༌ૹۀքͷඪ४తͳ׳शͱͯ͠ɺճͷߤւͰͦͷધഫ͕ ӡൖͰ͖ΔྔΑΓଟ͘ͷ՟෺Λड͚෇͚Δɻ͜ΕΛΦʔ όʔϒοΩϯάͱ͍͏ɻ w ͨͱ͑͹ɺऩ༰ೳྗͷΛ༧໿Ͱ͖ΔΑ͏ʹ͢Δ ͳͲɺओཁސ٬΍ಛఆͷ՟෺Λ༏ઌͯ͠ɺΑΓෳࡶͳ ϧʔϧΛద༻͢Δ৔߹΋͋Δ w

    ༌ૹۀքͰ͸୭Ͱ΋஌͍ͬͯΔ஌͕ࣝͩɺ։ൃऀશһ͕ ೺Ѳ͍ͯ͠Δͱ͸ݶΒͳ͍ɻཁٻఆٛॻʹ͸ɺzͷ ΦʔόʔϒοΩϯάΛೝΊΔzͷҰจ͕ॻ͔Ε͍ͯΔ
  26. ҉໧తͳ஌͕ࣝӅΕ͍ͯΔ w ։ൃऀ͕खॿ͚ͯ͠΋υϝΠϯΤΩεύʔτ͕ίʔυΛಡΜͰɺϧʔ ϧ͕ਖ਼͍͔͠ΛݕূͰ͖ͦ͏ʹͳ͍ ӳޠؤுΖ͏ɻ·ͣ͸೔ຊޠ Ͱ΋ڞ௨ݴޠͰձ࿩͕Ͱ͖Δఔ౓͕ඞཁ ɻ w Ϗδωεʹ͍ͭͯ஌Βͳ͍ٕज़ऀ͕ɺཁٻఆٛॻͷهड़Λίʔυ ͷهड़ͱ݁ͼ͚ͭΔ͜ͱ͕೉͍͠

    ͋ͨ͞͠Γͪ͜Βͷํ͕ਂࠁ ɻ w ϧʔϧ͕͞ΒʹෳࡶʹͳΔͱ໰୊͕͞ΒʹෳࡶʹͳΔɻ
  27. Ӆ͞Εͨ֓೦ΛܗࣜԽ͢Δ w ΦʔόʔϒοΩϯάΛ୯ͳΔΘ͔Γʹ͍͘ܭࢉͱ͢ΔͷͰ͸ͳ͘ɺ ໌֬ͰॏཁͳϏδωεϧʔϧͩͱཧղ͢ΔΑ͏ʹ͢Δɻ w ։ൃऀ͸υϝΠϯΤΩεύʔτʹυϝΠϯίʔυʹରԠٕͨ͠ज़ తͳ੒Ռ෺ΛݟͤΔ͜ͱ͕Ͱ͖Δɻͦ͏͢Δ͜ͱͰϑΟʔυόο Ϋϧʔϓ͕Ͱ͖͕͋Δ ӳޠؤுΖ͏ ɻ

  28. ਂ͍Ϟσϧͷ୳ٻ w ໰୊ͷ֩৺Λಥ͘Α͏ͳ༏ΕͨϞσϧਂ͍Ϟ σϧ w ࠷ॳ͔Β໾ʹཱͭϞσϧ͕खʹೖΔ͜ͱ͸Ίͬ ͨʹͳ͍ɻࢼߦࡨޡͷதͰൃݟͰ͖Δɻ w ࠷ॳͷཧ૝తͰͳ͍݁ՌͰ͋ͬͨͱ΋ɺܧଓֶ श͕ػೳ͢Δ࢓૊ΈΛνʔϜ಺ʹߏங͓ͯ͘͠ɻ

    ˠϑΟʔυόοΫϧʔϓΛ࣮ݱ͢Δ͜ͱ͕ॏཁɻ
  29. ϢϏΩλεݴޠ ʢ%%%ͷ࠷ॏཁઃܭύλʔϯ

  30. ϢϏΩλεݴޠ υϝΠϯ ΤΩεύʔτ ιϑτ΢ΣΞ ΤΩεύʔτ ϢϏΩλε ݴޠ ઐ໳༻ޠ ઐ໳༻ޠ ڞ௨༻ޠ

  31. ϢϏΩλεݴޠͳ͍৔߹ ઐ໳༻ޠ" ઐ໳༻ޠ# ຋༁ ຋༁ऀ υϝΠϯ ΤΩεύʔτ ιϑτ΢ΣΞ ΤΩεύʔτ ௨༁

    ௨༁ऀ
  32. ͍ͭ΋͏·͘௨༁Ͱ͖Δͱ͸ݶΒͳ͍ υϝΠϯϞσϧΛίΞʹίϛϡχέʔγϣϯͰ͖͍ͯͳ ͍ͱɺίετ͕ߴ͍ɻਖ਼֬ੑ΋๡͘͠ɺ଎౓΋஗͍ɻ

  33. ϢϏΩλεݴޠ ໰୊ w ௨༁͢Δ͜ͱͰυϝΠϯϞσϧͷ֓೦Λࠞཚͤͯ͞͠ ·͏ɻͦΕ͕ίʔυͷഁյతͳϦϑΝΫλϦϯάʹͭ ͳ͕Δɻ w ༷ʑͳνʔϜϝϯό͕༻ޠΛผͷҙຯͰ࢖͍ͳ͕Βɺ ͦͷ͜ͱΛೝࣝͯ͠ͳ͍ͱɺ੔߹ੑͷͱΕ͍ͯͳ͍ɺ ৴པͰ͖ͳ͍ιϑτ΢ΣΞ͕Ͱ͖͕͋Δɻ

    w ௨༁ʹ͔͔Δίετͷ͍ͤͰɺ஌ࣝͱߟ͑ํʹؔ͢Δ ަྲྀ͕๦͛ΒΕΔ͕ɺ͜ͷަྲྀ͕ͦ͜Ϟσϧʹର͢Δ ਂ͍ಎ࡯Λ༩͑Δɻ
  34. ϢϏΩλεݴޠ ղܾ w ޡղͷϦεΫΛ཈͑ΔͨΊʹɺڞ௨ݴޠΛج൫ͱ͢Δɻ ͜ͷݴޠ͸νʔϜͷ࡞ۀͷ͍ͨΔͱ͜Ζʹଘࡏ͢Δɻ w ϢϏΩλεݴޠʹ͸ɺΫϥε΍ϝιουɺϓϩύςΟ ͷ໊લ΍ϧʔϧؚ͕·ΕΔɻ։ൃऀؒͰར༻͞Εɺγ εςϜ͚ͩͰ͸ͳ͘ɺλεΫ΍ػೳΛهड़͢ΔͨΊʹ ΋ར༻͞ΕΔɻ

    w ։ൃऀͱυϝΠϯΤΩεύʔτ͕͓ޓ͍ʹҙࢥૄ௨Λ ͢Δࡍʹ΋ར༻͞ΕΔɻυϝΠϯΤΩεύʔτಉ͕࢜ ཁ݅΍։ൃܭըɺ͋Δ͍͸ػೳΛ఻͑߹͏ࡍʹ΋ར༻ ͞ΕΔɻ w Ұ੾ͷ௨༁Λෆཁ͠ɺυϝΠϯʹର͢ΔཧղΛΑΓε Ϝʔζͳ΋ͷͱ͢Δɻ
  35. ڞ௨ݴޠج൫Λ࢖ͬͯ௨༁Λͳ͘͢

  36. υϝΠϯͱͦΕҎ֎ Ոܭ฽αʔϏεͷ৔߹ Պ໨͝ͱͷຖ݄ͷ߹ܭֹۚΛूܭͰ͖Δ Ոܭ฽ೖྗϘλϯΛԡ͢ͱೖྗը໘ʹਪҠ͢Δ Ոܭ฽ͷฤूཤྺΛ)*4503:ςʔϒϧʹอଘ͢Δ ࢒ֹ͸ཌ݄ʹ܁ΓӽͤΔ ຖ݄ͷకΊ೔ΛઃఆͰ͖Δ Պ໨͝ͱͷຖ݄ͷ༧ࢉΛઃఆͰ͖Δ ग़ೲֹͱͯ͠਺஋Ҏ֎Λೖྗͨ͠ΒΤϥʔ

  37. υϝΠϯͱͦΕҎ֎ Ոܭ฽αʔϏεͷ৔߹ Պ໨͝ͱͷຖ݄ͷ߹ܭֹۚΛूܭͰ͖Δ Ոܭ฽ೖྗϘλϯΛԡ͢ͱೖྗը໘ʹਪҠ͢Δ Ոܭ฽ͷฤूཤྺΛ)*4503:ςʔϒϧʹอଘ͢Δ ࢒ֹ͸ཌ݄ʹ܁ΓӽͤΔ ຖ݄ͷకΊ೔ΛઃఆͰ͖Δ Պ໨͝ͱͷຖ݄ͷ༧ࢉΛઃఆͰ͖Δ ग़ೲֹͱͯ͠਺஋Ҏ֎Λೖྗͨ͠ΒΤϥʔ

  38. υϝΠϯͱͦΕҎ֎ Ոܭ฽αʔϏεͷ৔߹ Պ໨͝ͱͷຖ݄ͷ߹ܭֹۚΛूܭͰ͖Δ Ոܭ฽ೖྗϘλϯΛԡ͢ͱೖྗը໘ʹਪҠ͢Δ Ոܭ฽ͷฤूཤྺΛ)*4503:ςʔϒϧʹอଘ͢Δ ࢒ֹ͸ཌ݄ʹ܁ΓӽͤΔ ຖ݄ͷకΊ೔ΛઃఆͰ͖Δ Պ໨͝ͱͷຖ݄ͷ༧ࢉΛઃఆͰ͖Δ ग़ೲֹͱͯ͠਺஋Ҏ֎Λೖྗͨ͠ΒΤϥʔ

  39. ඇυϝΠϯίʔυ 6*Λඳը͢Δίʔυ %#͔Βඞཁ৘ใΛಡΈग़͢ίʔυ Ϣʔβ͕ೖྗͨ͠৘ใΛղऍɾݕূ͢ Δίʔυ ૢ࡞݁ՌΛ%#ʹίϛοτ͢Δίʔυ

  40. υϝΠϯίʔυ Պ໨ͳͲͷબ୒ࢶΛϧʔϧʹैͬͯબ ผ͢Δίʔυ ݄͝ͱͷ࣮੷ΛଋͶΔίʔυ ݄͝ͱͷ߹ܭֹۚΛܭࢉ͢Δίʔυ ຖ݄ͷ༧࣮ΛධՁ͢Δίʔυ

  41. υϝΠϯίʔυ Պ໨ͳͲͷબ୒ࢶΛϧʔϧʹैͬͯબ ผ͢Δίʔυ ݄͝ͱͷ࣮੷ΛଋͶΔίʔυ ݄͝ͱͷ߹ܭֹۚΛܭࢉ͢Δίʔυ ຖ݄ͷ༧࣮ΛධՁ͢Δίʔυ

  42. ϢϏΩλεݴޠ ʹ͸ڥք͕͋Δ

  43. ڥք෇͚ΒΕͨίϯςΩετ #$ ͜Ε͸Կʹݟ ͑Δ͔ʁ

  44. ڥք෇͚ΒΕͨίϯςΩετ #$ ϧϏϯͷᆵ ਤͱ஍͕ᐆດͳֆ നΛ஍ͱΈΕ͹ɺإ ࠇΛ஍ͱΈΕ͹ɺՖළ ಉ͡ه߸ͳʹҙຯ͕ҧ͏

  45. ΞΧ΢ϯτͷྫ ΞΧ΢ϯτͬͯ ͳΜͩΖ͏ʁ

  46. ΞΧ΢ϯτϞσϧ ΞΧ΢ϯτ Ͳ͏ߟ͑ͯ΋ Ϣʔβͷ ΞΧ΢ϯτʁ

  47. ҧ͍·͢ʂۜߦޱ࠲Ͱ͢ʂ ΞΧ΢ϯτ ۜߦίϯςΩετ ۜߦޱ࠲

  48. ҧ͍·͢ʂݸਓͷه࿥Ͱ͢ʂ ΞΧ΢ϯτ จֶίϯςΩετ ݸਓͷه࿥

  49. ͜Ε͸ࠞͥͯ͸ͳΒͳ͍ ΞΧ΢ϯτ ΞΧ΢ϯτ ۜߦίϯςΩετ จֶίϯςΩετ ݸਓͷه࿥ ۜߦޱ࠲ ڥքΛઃఆ

  50. ڥք෇͚ΒͨίϯςΩετͷҧ͍ #$ͷҧ͍ʹΑΓϞσϧ͕ҟͳΔ యܕతͳࣄྫ

  51. ౷߹͠ͳ͍ઃܭઓུ

  52. ߥ࡟Γʹ౷߹͢Δઃܭઓུ

  53. ஌ࣝͷ͔Έࡅ͖ʹΑͬͯ౷߹ͨ͠ྫ

  54. ίϯ΢ΣΠͷ๏ଇ w γεςϜΛઃܭ͢Δ͋ΒΏΔ૊৫͸ɺඞ ͣͦͷ૊৫ͷίϛϡχέʔγϣϯߏ଄ʹ ฿ ͳΒ ͬͨߏ଄Λ࣋ͭઃܭΛੜΈग़͢ɻ w ͭ·Γɺ૊৫ͷߏ଄͸γεςϜͷߏ଄ͱ ἧ͑ͯͳ͚Ε͹ͳΒͳ͍ɻ

  55. ૊৫͸ΞʔΩςΫνϟʹ౤Ө͞ΕΔ ʙΠϊϕʔγϣϯͷδϨϯϚΑΓʙ

  56. γεςϜͷڥքʹ૊৫ͷڥք ൢച؅ཧࡏݿ؅ཧސ٬؅ཧ ͷͦΕͧΕͰ Ϟσϧʹର͢Δ ͱΒ͑ํ͕มΘΔ ސ٬͔Βۤ৘͕͖ͯ ͳ͍͔ͳʁ ͜ͷ঎඼͸Ҿ͖౰͕ͯ ͋Δͳ͍ʁ ͜ͷ঎඼͸Ͳ͏͍͏૚ͷ

    ސ٬ʹചΕ͍ͯΔͷ͔ͳʁ
  57. γεςϜͷڥքʹ૊৫ͷڥք ൢച؅ཧࡏݿ؅ཧސ٬؅ཧ ͷͦΕͧΕͰ Ϟσϧʹର͢Δ ͱΒ͑ํ͕มΘΔ ސ٬͔Βۤ৘͕͖ͯ ͳ͍͔ͳʁ ͜ͷ঎඼͸Ҿ͖౰͕ͯ ͋Δͳ͍ʁ ͜ͷ঎඼͸Ͳ͏͍͏૚ͷ

    ސ٬ʹചΕ͍ͯΔͷ͔ͳʁ ૊৫ͷߏ଄͸༰қʹ มߋ͠ͳ͍ͨΊ ͜ͷ๏ଇ͸ ؆୯ʹ͋Β͕͑ͳ͍
  58. ϞδϡʔϧͷڥքʹνʔϜͷڥք

  59. ಺֎Ͱ༗ػతʹ૬ޓ࡞༻͢Δ 8FC 'BMDPO $MJFOU

  60. ༧໿ ઐ༻୺຤෦໳ͷ෦ॺɾऔҾઌ ཱྀఔ࡞੒ ཱྀఔ ঎඼ ݟੵ ސ٬ ܦཧ ސ٬ ৼࠐ

    ίϯςΩετϚοϓ Ұ෦ͷ৘ใΛ ఏڙ ม׵
  61. ༧໿ ઐ༻୺຤෦໳ͷ෦ॺɾऔҾઌ ཱྀఔ࡞੒ ཱྀఔ ঎඼ ݟੵ ސ٬ ܦཧ ސ٬ ৼࠐ

    ૊৫ͱΞʔΩςΫνϟͷத֩ʹ͸ υϝΠϯϞσϧ͕ଉͮ͘ ίϯςΩετϚοϓ Ұ෦ͷ৘ใΛ ఏڙ ม׵
  62. Ϟσϧۦಈઃܭ ΤϯδχΞͷਓ޲͚ ྫ͸ዞҙతͰ͢ʜ

  63. Ϟσϧۦಈઃܭ ໰୊ w ͔࣍Β࣍΁ͱػೳΛຬ͚ͨͩ͢ͷίʔυ͸ɺ஌ࣝͷ ͔Έࡅ͖ͱίϛϡχέʔγϣϯͷԸܙΛ΄ͱΜͲड ͚ͳ͍ɻͦ͏ͨ͠ϓϩδΣΫτ͸ෳࡶͳυϝΠϯʹૺ ۰ͨ࣌͠ʹख΋଍΋Ͱͳ͍ɻ w ଟ͘ͷϓϩδΣΫτ͸ԿΒ͔ͷυϝΠϯϞσϧΛࢼ͠ ͍ͯΔ͕ɺϞσϧͱίʔυͷ݁ͼ͖͕ͭݫີͰ͸ͳ͍ɻ

    ࠷ॳ͸ௐࠪஈ֊Ͱ͸໾ʹཱ͕ͭɺঃʑʹత֎ΕʹͳΓ ޡղΛট͘Մೳੑ͕͋ΔɻϞσϧͱίʔυ͕ผ΋ͷ ͳͷͰɺઃܭ͕ਖ਼͍͠ͱ͍͏҆৺ײ͸ͳ͍ɻ
  64. Ϟσϧͷछྨ w υϝΠϯϞσϧ ෼ੳ ʹυϝΠϯͷߟ͑ํ ֓೦ Λ൓ө ͨ͠΋ͷɻ໰୊ͷղ͘ߟ͑ํͦͷ΋ͷΛࢦ͢ɻϢϏΩ λεݴޠͰදݱ͞ΕΔɻ w

    ιϑτ΢ΣΞϞσϧ ઃܭ ʹιϑτ΢ΣΞ্ͰυϝΠϯ ϞσϧΛදݱͨ͠΋ͷɻ w ΦϒδΣΫτϞσϧ ࣮૷ ʹιϑτ΢ΣΞϞσϧΛίʔ υ্ʹ࣮૷ͨ͠΋ͷɻϓϩάϥϛϯάݴޠΛ࢖ͬͯද ݱ͞ΕΔɻ
  65. Ϟσϧͷछྨ w υϝΠϯϞσϧ ෼ੳ ʹυϝΠϯͷߟ͑ํ ֓೦ Λ൓ө ͨ͠΋ͷɻ໰୊ͷղ͘ߟ͑ํͦͷ΋ͷΛࢦ͢ɻϢϏΩ λεݴޠͰදݱ͞ΕΔɻ w

    ιϑτ΢ΣΞϞσϧ ઃܭ ʹιϑτ΢ΣΞ্ͰυϝΠϯ ϞσϧΛදݱͨ͠΋ͷɻ w ΦϒδΣΫτϞσϧ ࣮૷ ʹιϑτ΢ΣΞϞσϧΛίʔ υ্ʹ࣮૷ͨ͠΋ͷɻϓϩάϥϛϯάݴޠΛ࢖ͬͯද ݱ͞ΕΔɻ ϞσϧۦಈઃܭͰ͸ɺυϝΠϯ ϞσϧͱίʔυΛ෼཭ͤͣʹ ୯ҰͷϞσϧͰදݱ͢Δ
  66. Ϟσϧۦಈઃܭ ղܾ w ෼ੳɾઃܭɾ࣮૷͸୯ҰͷϞσϧʹΑͬͯۦಈ͢ Δɻͭ·Γɺઃܭ͕ίʔυͰ͋Γɺίʔυ͕ઃܭͰ ͋Δͱ͍͏ঢ়ଶΛ࡞Γग़͢ɻ͜ΕʹΑͬͯɺઃܭͷ ؒҧ͍Λൃݟ͢Δ͜ͱ͕Ͱ͖Δɻ w ࣮૷ΛϞσϧʹ݁ͼ͚ͭΔͨΊʹɺ௨ৗɺΦϒδΣ Ϋτࢦ޲ϓϩάϥϛϯάͷΑ͏ͳύϥμΠϜΛར༻

    ͢Δɻ w ؔ਺ܕ΍࿦ཧܕͳͲΛࠞ߹ͨ͠ύϥμΠϜͰ΋Α ͍͕ɺओ࣠͸001ɻͦΕ͸։ൃऀͷ਺΍҆ఆͨ͠ ։ൃ؀ڥʹґଘ͍ͯ͠Δɻͦ͏͍͏ҙຯͰ͸ɺ 4DBMB͸001ͱ'1ͷ྆ํͰϞσϦϯάͷબ୒ࢶΛ ޿͛ΒΕΔɺݱ࣮తͳϓϥοτϑΥʔϜͱ͍͑Δɻ
  67. ޱ࠲ͷϢϏΩλεݴޠͷྫ w ޱ࠲ʹݱۚͰೖग़ۚͰ͖Δ w ͨͩ͠ɺ࢒ߴ͸θϩະຬʹͳͬͯ͸ͳΒͳ͍ɻ w ޱ࠲͸ଞͷޱ࠲ʹग़ۚɺ΋͘͠͸ଞͷޱ࠲͔Β ೖۚͰ͖Δɻ w ޱ࠲ͷ࢒ߴΛ֬ೝͰ͖Δ

    w ͓ۚ͸ଞͷ͓ۚΛՃݮࢉͰ͖Δɻݮࢉ͸ෛͷྔ ΛՃࢉ͢ΔҙຯͰ΋Α͍ɻ w ͨͩ͠ɺಉҰޱ࠲ͳ͍Ͱ͸ɺಉ͡௨՟୯ҐͷΈ Λѻ͏
  68. ޱ࠲υϝΠϯΦϒδΣΫτͷఆٛ @Value
 public final class BankAccount {
 @NonNull
 private Long

    id;
 @NonNull
 private List<BankAccountEvent> events;
 
 
 public BankAccount depositCash(Money money) {
 return addBankAccountEvent(id, null, money);
 }
 
 public BankAccount withdrawCash(Money money) {
 return addBankAccountEvent(null, id, money.negated());
 }
 
 public BankAccount depositFrom(BankAccount from, Money money) {
 return addBankAccountEvent(id, from.getId(), money);
 }
 
 public BankAccount withdrawTo(BankAccount to, Money money) {
 return addBankAccountEvent(to.getId(), id, money.negated());
 }
 
 public Money getTotalAmount() {
 return getTotalAmountByEvents(events);
 } private BankAccount addBankAccountEvent(Long toBankAccountId, 
 Long fromBankAccountId, Money money) {
 Long eventId = IdGenerator.generateId();
 return addBankAccountEvent(BankAccountEvent.of(eventId, id, null, money));
 }
 
 private BankAccount addBankAccountEvent(BankAccountEvent event) {
 List<BankAccountEvent> result = Lists.newArrayList(events);
 result.add(event);
 return of(id, result);
 }
 } ݱۚೖۚ ݱۚग़ۚ ଞͷޱ࠲ʹग़ۚ ଞͷޱ࠲͔Βೖۚ ೖग़ۚΠϕϯτ͔Β࢒ߴΛฦ͢ ॏཁͳ͜ͱϝιουΛ ϢϏΩλεݴޠʹඥ෇͚Δ
  69. ޱ࠲υϝΠϯΦϒδΣΫτͷ੍໿ @Value
 public final class BankAccount { // தུ public

    static BankAccount of(Long id, List<BankAccountEvent> events) {
 if (getTotalAmountByEvents(events).isLessThan(Money.zero())) {
 throw new IllegalArgumentException("total amount is less than zero!");
 }
 return new BankAccount(id, events);
 } // தུ } ޱ࠲ͷ࢒ߴ͸θϩະຬʹͳͬͯ͸ͳΒͳ͍
  70. ޱ࠲υϝΠϯΦϒδΣΫτͷ࢖͍ํ Money baseMoney = Money.of(10000);
 BankAccount bankAccount1 = BankAccount.of(IdGenerator.generateId())
 .addIncrementAmount(baseMoney);

    ӳޠͬΆ͘ͳΔ͕ɺϏδωεαΠυͷਓ͕ͨͪ શ͘ཧղͰ͖ͳ͍Θ͚Ͱ͸ͳ͍ʁʁ ӳޠͬΆ͘ͳΔ͕ɺϏδωεαΠυͷਓ͕ͨͪ શ͘ཧղͰ͖ͳ͍Θ͚Ͱ͸ͳ͍ʁʁ
  71. ශ݂঱ޱ࠲ΦϒδΣΫτͷఆٛ public class BankAccount { 
 private Long id;
 private

    List<BankAccountEvent> events;
 
 public BankAccount() {
 }
 
 public Long getId() {
 return this.id;
 }
 
 public List<BankAccountEvent> getEvents() {
 return this.events;
 }
 
 public void setId(Long id) {
 this.id = id;
 }
 
 public void setEvents(List<BankAccountEvent> events) {
 this.events = events;
 }
 
 } w HFUUFSTFUUFS͔͠ͳ͍ͨ ͩͷσʔλͷೖΕ෺ w υϝΠϯϞσϧͱ࣮૷͕ ෼཭͞Ε͓ͯΓɺॏཁͳ ֓೦Λ఻͑ΒΕ͍ͯͳ ͍ɻͦ΋ͦ΋͜ΕͰ͸֓ ೦ͷཧղ͕͕ͨ͘͠ό άͷԹচʹ΋ͳΓ΍͢ ͍ɻ·ͨɺϏδωεͷ ઓུมߋʹ΋௥ै͠ʹ ͍͘ɻ w ΋ͬͱίʔυʹ֓೦Λ ޠΒͤΔ΂͖Ͱ͋Δɻ
  72. ශ݂঱ޱ࠲ΦϒδΣΫτͷ࢖͍ํ Money baseMoney = new Money();
 baseMoney.setCurrency(Currency.getInstance("JPY"));
 baseMoney.setAmount(BigDecimal.valueOf(10000));
 BankAccount bankAccount1

    = new BankAccount();
 bankAccount1.setId(IdGenerator.generateId());
 List<BankAccountEvent> events1 = Lists.newArrayList();
 BankAccountEvent incrementEvent1 = new BankAccountEvent();
 incrementEvent1.setId(IdGenerator.generateId());
 incrementEvent1.setToBankAccountId(bankAccount1.getId());
 incrementEvent1.setFromBankAccountId(null);
 incrementEvent1.setAmount(baseMoney);
 incrementEvent1.setOccurredAt(ZonedDateTime.now());
 events1.add(incrementEvent1);
 bankAccount1.setEvents(events1); ͯ͞ɺ༰қʹཧղͰ͖ΔίʔυͰ͠ΐ͏͔ʁ ޱ࠲࢒ߴ͕θϩະຬʹͳΒͳ͍ͱ͍͏ ߟ͑ํΛ࣮ࣔͨ͠૷Ͱ͠ΐ͏͔ʁ
  73. ͓ۚͷϢϏΩλεݴޠͷྫ w ͓ۚ͸୯ͳΔ਺஋ʁ-POH  w Ճݮࢉ͸਺஋ ਺஋ ਺஋਺஋  w

    ݫີʹ͸ɺ਺஋ʹ͓ۚͰ͸ͳ͍ͷͰ͸ʁ࣮ࡍʹίʔυ Ͱ-POHΛΈͯ΋͓͔ۚͲ͏͔͸Θ͔Βͳ͍ɻυϝΠϯ ্ͷ֓೦Λ࣮૷ʹඥ෇͚ΒΕ͍ͯͳ͍Մೳੑ͕͋Δɻ w ྫ͑͹ɺl͓ۚͱ͸ɺ௨՟ͷ୯ҐͱྔΛද͢΋ͷͰ͋Δz ͱ͍͏ϢϏΩλεݴޠΛ࡞Γ্͛Δɻ͓ۚͷྔ͸਺஋ Ͱ΋Α͍ͱ͢Δɻ
  74. ͓ۚυϝΠϯΦϒδΣΫτͷఆٛ @Value
 public final class Money {
 @NonNull
 private BigDecimal

    amount;
 @NonNull
 private Currency currency;
 
 
 public Money negated() {
 return of(amount.negate(), currency);
 }
 
 public Money plus(Money other) {
 Validate.notNull(other);
 Validate.isTrue(currency.equals(other.currency));
 return of(amount.add(other.amount), currency);
 }
 
 public Money minus(Money other) {
 return plus(other.negated());
 }
 
 public static Money sum(List<Money> monies) {
 if (monies.isEmpty()) {
 return zero(Money.DefaultCurrency);
 } else {
 Currency currency = monies.get(0).getCurrency();
 Money result = zero(currency);
 for (Money money : monies) {
 result = result.plus(money);
 }
 return result;
 }
 }
 
 public boolean isLessThan(Money other) { return isLessThan(other.amount); }
 
 public boolean isLessThan(BigDecimal amount) { return amount.compareTo(amount) < 0; }
 
 } ࢒ֹ͸ɺෳ਺ͷ͓ۚΛ߹ࢉ ͍ͯ͠Δɻ͓ۚࣗ਎͕Ճࢉ ϝιουΛ͓࣋ͬͯΓɺͦ ͷޠኮΛཧղͰ͖Ε͹߹ࢉ ࣗମͷཧղ΋͠΍͍͢ εέʔ ϥϒϧͳίʔυ Ճࢉͱ͍͏ϢϏΩλεݴޠ ͕Θ͔Ε͹ɺݮࢉࣗମ΋ཧ ղ͕ൺֱత༰қ
  75. ͓ۚυϝΠϯΦϒδΣΫτͷ࢖͍ํ Money money1 = Money.of(10000);
 Money money2 = Money.of(10000);
 Money

    result = money1.plus(money2);
 if (result.isLessThan(Money.zero())) {
 System.out.println("result is less than zero!");
 }
 System.out.println(result);
  76. ශ݂঱͓ۚΦϒδΣΫτͷఆٛ public class Money {
 
 private BigDecimal amount;
 private

    Currency currency;
 
 public Money() {
 }
 
 public BigDecimal getAmount() {
 return this.amount;
 }
 
 public Currency getCurrency() {
 return this.currency;
 }
 
 public void setAmount(BigDecimal amount) {
 this.amount = amount;
 }
 
 public void setCurrency(Currency currency) {
 this.currency = currency;
 }
 
 }
  77. ශ݂঱͓ۚΦϒδΣΫτͷ࢖͍ํ Money money1 = new Money();
 money1.setCurrency(Currency.getInstance("JPY"));
 money1.setAmount(BigDecimal.valueOf(10000));
 
 Money

    money2 = new Money();
 money2.setCurrency(Currency.getInstance("JPY"));
 money2.setAmount(BigDecimal.valueOf(10000));
 
 BigDecimal total = money1.getAmount().add(money2.getAmount());
 
 Money result = new Money();
 result.setCurrency(money1.getCurrency());
 result.setAmount(total); ؒҧ͍Ͱ͸ͳ͍͕ɺΘ͔Γʹ͍͘ɻ ΦϒδΣΫτࢦ޲ͷྑ͕͞ࡴ͞ΕΔ
  78. ޱ࠲ؒૹۚυϝΠϯαʔϏεͷఆٛ public final class BankAccountService {
 
 @Value
 public static

    class Result {
 private BankAccount to;
 private BankAccount from;
 }
 
 public static Result transfer(BankAccount to, BankAccount from, Money amount) {
 BankAccount updatedFrom = from.addDecrementEvent(to, amount);
 BankAccount updatedTo = to.addIncrementEvent(from, amount);
 return new Result(updatedTo, updatedFrom);
 }
 
 }
 ೋͭͷϞσϧঢ়ଶ͕׬શͳঢ়ଶͳΒͳ ͍ͱ͍͚ͳ͍ͷͰαʔϏεͰखଓ͖Խ ͢Δ͜ͱ͕͋Δɻ ͜ͷ৔߹Ͱ΋ɺϢϏΩλεݴޠΛ࢖ͬ ͨεΫϦϓτͷΑ͏ʹͳΔͷͰɺԿ͕ ى͜Δ͔ཧղ͠΍͍͢ɻ े෼ʹந৅Խ͞Ε͍ͯΔͷͰཧղ͠΍͍͢
  79. ޱ࠲ؒૹۚυϝΠϯαʔϏεͷ࢖͍ํ Money baseMoney = Money.of(10000);
 // ޱ࠲Λએݴ͠ɺॳظೖۚΛߦ͏
 BankAccount bankAccount1 =

    BankAccount.of(IdGenerator.generateId())
 .addIncrementAmount(baseMoney);
 BankAccount bankAccount2 = BankAccount.of(IdGenerator.generateId())
 .addIncrementAmount(baseMoney);
 
 System.out.println("bankAccount1 = " + bankAccount1.getTotalAmount());
 System.out.println("bankAccount2 = " + bankAccount2.getTotalAmount());
 
 // ޱ࠲ؒૹۚΛߦ͏
 BankAccountService.Result result = BankAccountService.transfer(
 bankAccount1,
 bankAccount2,
 Money.of(10000)
 );
 
 System.out.println("to = " + result.getTo().getTotalAmount());
 System.out.println("from = " + result.getFrom().getTotalAmount()); νʔϜͰ࡞ͬͨɺݴޠʹΑͬͯϩδοΫ͕ߏ੒͞ΕΔɻ
  80. ශ݂঱ޱ࠲ؒૹۚαʔϏε public class BankAccountService {
 @Data
 public static class Result

    {
 private BankAccount to;
 private BankAccount from;
 }
 
 public static Result moveData(BankAccount to, BankAccount from, Money amount) {
 BigDecimal totalAmount = BigDecimal.ZERO;
 for(BankAccountEvent event : to.getEvents()) {
 totalAmount = totalAmount.add(event.getAmount().getAmount());
 }
 if (totalAmount.compareTo(amount.getAmount()) < 0) {
 throw new IllegalArgumentException("total amount is less than zero!");
 }
 BankAccountEvent decrementEvent = new BankAccountEvent();
 decrementEvent.setId(IdGenerator.generateId());
 decrementEvent.setFromBankAccountId(from.getId());
 decrementEvent.setToBankAccountId(to.getId());
 Money negated = new Money();
 negated.setCurrency(amount.getCurrency());
 negated.setAmount(amount.getAmount().negate());
 decrementEvent.setAmount(negated);
 decrementEvent.setOccurredAt(ZonedDateTime.now());
 BankAccount newFrom = new BankAccount();
 List<BankAccountEvent> newFromEvent = Lists.newArrayList(from.getEvents());
 newFromEvent.add(decrementEvent);
 newFrom.setId(from.getId());
 newFrom.setEvents(newFromEvent);
 
 BankAccountEvent incrementEvent = new BankAccountEvent();
 incrementEvent.setId(IdGenerator.generateId());
 incrementEvent.setFromBankAccountId(from.getId());
 incrementEvent.setToBankAccountId(to.getId());
 incrementEvent.setAmount(amount);
 incrementEvent.setOccurredAt(ZonedDateTime.now());
 BankAccount newTo = new BankAccount();
 List<BankAccountEvent> newToEvent = Lists.newArrayList(to.getEvents());
 newToEvent.add(incrementEvent);
 newTo.setId(to.getId());
 newTo.setEvents(newToEvent);
 
 Result result = new Result();
 result.setFrom(newFrom);
 result.setTo(newTo);
 return result;
 
 }
 
 } ޱ࠲࢒ߴͷνΣοΫ͸ ޱ࠲ࣗ৴Ͱ͸ͳ͘ ϩδοΫͰؤுΔ ۩ମతա͗Δৄࡉʹ ѹ౗͞Εͯ͠·͏ʜɻ ػೳ͕ଟ͍ͱ໰୊͕ ͞ΒʹෳࡶʹͳΔɻ ίʔυͷॏෳʹ΋ؾ͖ͮʹ͍͘ɻ ͜ΕͰ͸υϝΠϯΤΩεύʔτ ͱͷؒʹ௨༁͕ඞཁʹͳΔ ݮࢉͷ֓೦͕҉໧஌Ͱ ཧղ͠ʹ͍͘
  81. ශ݂঱ޱ࠲ؒૹۚαʔϏεͷ࢖͍ํ Money baseMoney = new Money();
 baseMoney.setCurrency(Currency.getInstance("JPY"));
 baseMoney.setAmount(10000);
 // ޱ࠲Λએݴ͠ɺॳظೖۚΛߦ͏


    BankAccount bankAccount1 = new BankAccount();
 bankAccount1.setId(IdGenerator.generateId());
 List<BankAccountEvent> events1 = Lists.newArrayList();
 BankAccountEvent incrementEvent1 = new BankAccountEvent();
 incrementEvent1.setId(IdGenerator.generateId());
 incrementEvent1.setToBankAccountId(bankAccount1.getId());
 incrementEvent1.setFromBankAccountId(null);
 incrementEvent1.setAmount(baseMoney);
 incrementEvent1.setOccurredAt(ZonedDateTime.now());
 events1.add(incrementEvent1);
 bankAccount1.setEvents(events1);
 
 
 BankAccount bankAccount2 = new BankAccount();
 bankAccount2.setId(IdGenerator.generateId());
 List<BankAccountEvent> events2 = Lists.newArrayList();
 BankAccountEvent incrementEvent2 = new BankAccountEvent();
 incrementEvent2.setId(IdGenerator.generateId());
 incrementEvent2.setToBankAccountId(bankAccount1.getId());
 incrementEvent2.setFromBankAccountId(null);
 incrementEvent2.setAmount(baseMoney);
 incrementEvent2.setOccurredAt(ZonedDateTime.now());
 events2.add(incrementEvent2);
 bankAccount2.setEvents(events2);
 
 Money totalAmount1 = getTotal(bankAccount1);
 Money totalAmount2 = getTotal(bankAccount2);
 
 System.out.println("bankAccount1 = " + totalAmount1);
 System.out.println("bankAccount2 = " + totalAmount2);
 
 Money data = new Money();
 data.setCurrency(bankAccount1.getEvents().get(0).getAmount().getCurrency());
 data.setAmount(BigDecimal.valueOf(10000));
 // ޱ࠲ؒૹۚΛߦ͏
 BankAccountService.Result result = BankAccountService.moveData(
 bankAccount1,
 bankAccount2,
 data
 );
 
 Money newTotalAmount1 = getTotal(result.getTo());
 Money newTotalAmount2 = getTotal(result.getFrom());
 
 System.out.println("toTotalAmount = " + newTotalAmount1);
 System.out.println("fromTotalAmount = " + newTotalAmount2); ΋͸΍ίʔυΛಡΉؾʹͳΒ ͳ͍ɻυϝΠϯϞσϧ͕ࣔ͢ ߟ͑ํ͕े෼ʹ൓ө͞Ε͍ͯ ͳ͍ͨΊɺ͜ͷ࣮૷Λίϛϡ χέʔγϣϯʹ࢖͏͜ͱ͸೉ ͍͠ɻ
  82. Ϟσϧۦಈઃܭ w ۃ୺ͳྫΛ͕ࣔͨ͠ɺϢϏΩλεݴޠΛ ൓өͨ͠୯ҰͷϞσϧΛҙ͓͔ࣝͯ͠ͳ ͚Ε͹ɺந৅౓ͷߴ͍ɺΦϒδΣΫτϞ σϧΛߏங͢Δ͜ͱ͕೉͘͠ͳΔɻ w ΦϒδΣΫτϞσϧ΁ͷ൓ө͕Ͱ͖ͳ͚ Ε͹ɺ௨༁ʹཔΒ͟ΔΛಘͳ͘ͳΔ͠ɺ υϝΠϯ্ͷίʔυʹ΋ਖ਼͠͞͸දΕͳ

    ͍ɻ
  83. ':* ϢʔβετʔϦϚοϐϯάͱ*$0/*9

  84. *$0/*9ϓϩηεͱϢʔβετʔϦϚοϐϯά w શһ νʔϜͰϢʔβετʔϦϚοϐϯάˠϥϑͳυϝΠϯϞσϧ ˠϥϑͳϢʔεέʔεϞσϧΛ࡞Γͳ͕ΒɺॳظͷϢϏΩλεݴޠ Λ࡞Δ ඞཁʹԠͯ͡ΠϯελϯτͳࢴࣳډΛ࡞Δ ɻ w υϝΠϯϞσϧෆࡏͰϢʔεέʔεΛ࡞Δͱٕज़తৄࡉʹཱͪೖͬ

    ͯ͠·͍͕ͪͰɺϢϏΩλεݴޠ͕࡞Γʹ͍͘ɻϢʔεέʔεΛߟ ͍͑ͯ͘ͱ৽͍͠ݴ༿Λൃݟ͢Δ͜ͱ͕͋ΔˠυϝΠϯϞσϧΛվ గ͢Δɻ w ΤϯδχΞͷΈ ϩόετωε෼ੳ΍γʔέϯεਤ͸ෳࡶͳͱ͜Ζ ͚ͩʹߜΔ
  85. ϢʔβετʔϦϚοϐϯά w ࣌ܥྻʹϢʔβߦಈΛ͋Βग़͠ɺߦಈʹج͍ͮͯཁٻΛݟཱͯΔ ख๏ɻ w ؔ܎ऀ͕ू·Γɺ෇ᝦ΍໛଄ࢴΛ༻͍ͯϫʔΫγϣοϓΛߦ͏ɻ w ࢀՃऀͷ஌ݟΛੜ͔ͯ͠ɺཁٻΛൃݟɾચ͍ग़͢ɻ·ͨɺ༏ઌ౓ ෇͚Λߦ͏͜ͱͰείʔϓ ػೳൣғ

    Λ୹࣌ؒͰಛఆ͢Δ͜ͱ΋ Ͱ͖Δɻ ৔໘ ΞΫλʔ ετʔϦ ༏ઌ౓ߴ ༏ઌ౓௿ .71
  86. ࠷ॳʹυϝΠϯϞσϧީิΛચ͍ग़͢ • υϝΠϯϞσϦ ϯά • ϢʔβετʔϦ ϚοϐϯάΛ͠ ͳ͕ΒυϝΠϯ ϞσϧͷީิΛ ચ͍ग़͢ɻ

  87. ϢʔεέʔεϞσϦϯά • ϢʔεέʔεϞσϦϯά • υϝΠϯϞσϧΛݩʹϢʔ εέʔεΛهड़͢Δɻ • υϝΠϯϞσϦϯάͷ ༻ޠΛ࢖ͬͯɺϢʔβͷ ཁٻΛ໌֬ʹ͢Δɻ

    • υϝΠϯϞσϧʹͳ͍ݴ ༿͕ൃݟ͞ΕͨυϝΠ ϯϞσϧਤΛߋ৽͢Δɻ • ͨͩ͠ɺֆʹͩ͜ΘΔඞཁ ͸ͳ͍ɺҰཡදͰ΋Α͍ɻ
  88. ϢʔεέʔεͷγφϦΦ • Ϣʔεέʔεɹ هड़ͱ΋ݴΘ ΕΔ • ੖Εͷ೔͚ͩ Ͱͳ͘Ӎͷ೔ ΋ߟྀ͢Δ •

    ଟ͘ͷϢϏΩ λεݴޠ(ީิ) ΛൃݟͰ͖Δɻ
  89. ·ͱΊ w ෳࡶͳγεςϜ͸ɺυϝΠϯϞσϧΛίΞʹ͢Δ w ίϛϡχέʔγϣϯ͸ɺڞ௨ݴޠج൫Ͱ͋ΔϢϏ ΩλεݴޠΛ༻͍Δ w ૊৫ͱγεςϜͷڥքΛҙࣝ͢ΔͨΊʹɺڥքͮ ͚ΒΕͨίϯςΩετΛ༻͍Δ w

    υϝΠϯϞσϧΛ࣮૷ʹඥ෇͚ΔͨΊͷɺ୯Ұͷ ϞσϧΛ༻͍Δ w ࣮ફతʹ͸ɺϢʔβετʔϦϚοϐϯά΍*$0/*9 Λ༻͍Δ
  90. ͓͠·͍

  91. ࢀߟɾҾ༻ͨ͠εϥΠυ w IUUQTTTTMJEFDPNXXXTMJEFTIBSFOFU EBJTVLF@NEFWMPWFCFBVUJGVMEFWFMPQNFOU w IUUQTTTTMJEFDPNXXXTMJEFTIBSFOFU EJHJUBMTPVMJUEFWPQT