strategy of client side - DDD

3925ee6eaa41031bac799de0f4f528ec?s=47 to4iki
April 25, 2018

strategy of client side - DDD

3925ee6eaa41031bac799de0f4f528ec?s=128

to4iki

April 25, 2018
Tweet

Transcript

  1. ઓུతClient-DDD iOSϥϯνษڧձ 2018/04/25 @to4iki 1

  2. Agenda • DDDʹ͍ͭͯ(ઓུͷ؍఺Ͱͬ͟ͱઆ໌) • ΫϥΠΞϯταΠυͰ༗ޮͳͷ͔ߟ͑Δ • ·ͱΊ 2

  3. DDD 3

  4. DDD = ϨΠϠʔυΞʔΩςΫνϟͱ͍͏ೝࣝ͸ޡղΛੜ͡Δ DDDͷຊ౰ͷࢫຯ͸"ઓུ໘"ʹ͋Δ 4

  5. υϝΠϯۦಈઃܭ Domain Driven Design 5

  6. DDDͱ͸ • υϝΠϯϞσϧΛத৺ʹߟ͑Δઃܭࢥ૝ • DDD͸ݴ༿Λେ੾ʹ͢Δઃܭࢥ૝ • XP(ΠϯΫϦϝϯλϧͳઃܭ) + OO(ΦϒδΣΫτࢦ޲) •

    OOP > DDD ݪ఺ճؼͳ͚ͩɻैདྷͷԆ௕ઢ্ʹ͋Δ΋ͷ 6
  7. DDDͷ໨త͸ ιϑτ΢ΣΞͷ֩৺ʹ͋Δ ෳࡶੑͱઓ͏ࣄ 7

  8. 8

  9. ۜͷ஄ؙͰ͸ͳ͍ • ΦϒδΣΫτࢦ޲ઃܭͷݪཧओٛΛओு͢Δઃܭख๏Ͱ͸ͳ ͍ɻ఻౷తͳ͍͔ͭ͘ͷߟ͑ํΛجʹɺڧௐ͢Δ఺ΛͣΒͯ͠ ͍Δ • DDD͕޲͔ͳ͍৔໘΋΋ͪΖΜ͋Δ 9

  10. DDDͷҙٛ1 • Ϗδωεͷઐ໳Ո(υϝΠϯΤΩεύʔτ)ͱ։ൃऀΛ ಉ͡౔ඨʹ৐ͤΔࣄ Ͱɺ։ൃऀͷࢹ఺͚ͩͰͳ͘Ϗδωεଆͷࢹ఺΋౿·͑ͨιϑτ΢ΣΞ Λ࡞ ΕΔΑ͏ʹ͢Δ • ͦͷιϑτ΢ΣΞͷ֓೦Λཧղ͍ͯ͠ΔͷҰ෦ͷਓ(͍͍ͨͯ͸։ൃऀ)ͨͪͩ ͚ͱ͍͏ঢ়گΛͳ͘͢

    • υϝΠϯΤΩεύʔτͱ։ൃऀɺιϑτ΢ΣΞͦͷ΋ͷͱͷؒͰɺ௨༁Λෆ ཁͱ͢Δ 1 Θ͔ΔʂυϝΠϯۦಈઃܭ ʙ΋ͪͪ͜ΌΜͷେ๯ݥʙʲC91৽ץʳ 10
  11. FYI: ͱ͔͔ͬΓʹ ઓུతDDDͷࢫຯ͕؆ܿʹॻ͔Ε͍ͯΔ 11

  12. υϝΠϯͱ͸ʁ • ιϑτ΢ΣΞΛར༻͢Δਓͨͪͷ׆ ಈ"ͱ"ؔ৺ࣄ" • ιϑτ΢ΣΞͷ֩৺͸υϝΠϯʹؔ܎ ͨ͠໰୊ΛϢʔβͷͨΊʹղܾ͢Δೳ ྗͰ͋Δ2 • ͍ΘΏΔۀ຿ྖҬ(ιϑτ΢ΣΞͰղܾ

    ͍ͨ͠໰୊) 2 ΤϦοΫɾΤϰΝϯεͷυϝΠϯۦಈઃܭ 12
  13. ex. ϞϯελʔΛ౗͠ɺ Ϩϕϧ্͕͕ΔήʔϜͷυϝΠϯ(ۀ຿ྖҬ)Λߟ͑ͯΈΔ 13

  14. ϞϯελʔϋϯλʔGO(Ծ)ͷυϝΠϯ • ϓϨΠϠʔ͸ϞϯελʔΛ౗͢ • Ϟϯελʔͷ࢟͸ARٕज़ʹΑͬͯΧϝϥʹөͬͨ෩ܠʹ߹੒͞ ΕΔ • Ϟϯελʔͷ࢟͸ݱ࣮ੈքʹଘࡏ͢Δ͔ͷΑ͏ʹݟ͑ɺྟ৔ײ ͕͋Δ 14

  15. ϢϏΩλεݴޠ 15

  16. ͍ͭͰ΋ɾͲ͜Ͱ΋ɾ୭Ͱ΋ ࢖͑Δݴ༿ 16

  17. ϢϏΩλεݴޠ 17

  18. ϢϏΩλεݴޠ͕ແ͍ͱ • ϏδωεαΠυͱ։ൃऀͱͰಉ͡ࣄΛผʑʹݴ͍׵͍͑ͯͨΓ • ઐ໳༻ޠͷ௨༁ऀ͕ඞཁʹͳΔ • => ίετ͕ߴ͍ɺਖ਼֬ੑ΋๡͘͠ɺ଎౓΋஗͍ 18

  19. ڞ௨ݴޠج൫Λ࢖ͬͯ௨༁Λແ͘͢ Ոܭ฽αʔϏεͷ৔߹ͷυϝΠϯͱͦΕҎ֎ - ⭕ Պ໨ຖͷຖ݄ͷ߹ܭֹۚΛूܭͰ͖Δ - ❌ Ոܭ฽ͷฤूཤྺΛHISTORYςʔϒϧʹอଘ͢Δ - ⭕

    ࢒ֹ͸ཌ݄ʹ܁ΓӽͤΔ 19
  20. ϢϏΩλεݴޠ͕ղܾ͢ΔྖҬ • ೝࣝͷࠩҟΛ཈͑ΔͨΊʹɺڞ௨ݴޠΛج൫ͱ͢Δɻ͜ͷݴޠ ͸νʔϜͷ࡞ۀͷࢸΔॴʹଘࡏ͢Δ • Ұ੾ͷ௨༁Λෆཁ͠ɺυϝΠϯʹର͢ΔཧղΛΑΓεϜʔζͳ ΋ͷʹ͢Δ • ཧ૝͸Ϣʔβʔ͕࢖͏ݴ༿(ex. χίχίͷੜओɺεϨओ)

    20
  21. ͓·͚: ڥք͚ͮΒΕͨίϯςΩετ(BC) ΞΧ΢ϯτͬͯԿͰ͔͢ʁ Ϣʔβʔೝূͷ͜ͱΛࢦ͢ͷ͔ͳ 21

  22. ͓·͚: ڥք͚ͮΒΕͨίϯςΩετ(BC) • ݸਓͷه࿥(ใࠂॻ)ͱͯ͠ͷΞΧ΢ϯτ(จֶίϯςΩετ) • ޱ࠲ͱͯ͠ͷΞΧ΢ϯτ(ۜߦίϯςΩετ) • BCͷҧ͍ʹΑΓϞσϧ(ϢϏΩλεݴޠͷҙຯ߹͍)͕ҟͳΔ 22

  23. ϞϯελʔϋϯλʔGO(Ծ)ͷϢϏΩλεݴޠ • ϓϨΠϠʔ, ϋϯλʔ • ౗͢, ङΔ 23

  24. ϞϯελʔϋϯλʔGO(Ծ)ͷυϝΠϯ࠶ߟ • ϋϯλʔ͸ϞϯελʔΛङΔ • Ϟϯελʔͷ࢟͸ݱ࣮ੈքʹଘࡏ͢Δ͔ͷΑ͏ʹݟ͑Δ 24

  25. ͜ͷݴ༿ͷ௨Γʹɺίʔυʹ൓ө͢Δ ϋϯλʔ͸ϞϯελʔΛङΔ ↓ ϋϯλʔ(Hunter)Ϟσϧ͸Ϟϯελʔ(Monstor) ΛङΔ(hunt)ͱ͍͏ৼΔ෣͍Λ࣋ͭ 25

  26. υϝΠϯͷ஌ࣝ΍ৼΔ෣͍Λந৅Խ ͨ͠ͷ͕υϝΠϯϞσϧ 26

  27. υϝΠϯϞσϧ • ಛఆͷਤͰ͸ͳ͘ɺਤ͕఻͑Α͏ͱ͢ Δߟ͑ํΛࣔͨ͠΋ͷ 3 • Ϟσϧ͸ϓϩδΣΫτʹܞΘΔਓʑͷ ಄ͷதͰߏங͞Εͨ֓೦ͷू·Γ 3 ࣮ફυϝΠϯۦಈઃܭ

    27
  28. ͜͜·Ͱͷ·ͱΊ(খٳܜ) • DDD: υϝΠϯϞσϧΛத৺ʹߟ͑Δઃܭࢥ૝ • υϝΠϯ: ૊৫͕ߦ͏ࣄۀʹΑͬͯղܾ͍ͨ͜͠ͱ = ۀ຿ •

    υϝΠϯϞσϧ: υϝΠϯͷ஌ࣝ΍ৼΔ෣͍Λந৅Խͨ͠΋ͷ • ϢϏΩλεݴޠ: ͍ͭͰ΋ɾͲ͜Ͱ΋ɾ୭Ͱ΋࢖͑Δݴ༿ 28
  29. ຊ୊ Ͱ͸ɺΫϥΠΞϯταΠυͷ (υϝΠϯ)Ϟσϧʹ͍ͭͯߟ͑ͯΈΔ 29

  30. ΫϥΠΞϯταΠυϓϩάϥϛϯάͷ ओ໨త͸ʁ 30

  31. ΫϥΠΞϯταΠυϓϩάϥϛϯάͷ೉͍͠఺ 1. APIϨεϙϯεΛͲͷΑ͏ʹViewʹ൓ө͢Δ͔ 2. ෳࡶʹՄม͠͏Δσʔλͷঢ়ଶΛͲͷΑ͏ʹViewʹ൓ө͢Δ͔ 3. ཧ૝తͳUI/UXΛͲͷΑ͏ʹViewʹ൓ө͢Δ͔(࣮ݱ͢Δ͔) 31

  32. ΫϥΠΞϯτϓϩάϥϛϯάͷ೉͠͞ͷ8ׂͰ͋Γ׌ͭओ໨త͸ɺ ͲͷΑ͏ʹඳը͢Δ͔ (Viewʹ൓ө͢Δ͔)ͩͱࢥ͏ 32

  33. ΋͏Ұճ ΫϥΠΞϯταΠυͷϞσϧͬͯԿͩʁ 33

  34. 34

  35. ΫϥΠΞϯταΠυͷϞσϧ(1/2) • ❌ APIͷϨεϙϯεΛϚοϐϯάͨ͠ܕ • ❌ APIͷϨεϙϯεΛඳըʹదͨ͠ܗࣜʹม׵ͨ͠DTO • ⭕ αʔόαΠυ͕σʔλ૚ʹͳ͍ͬͯΔ৔߹͸ɺΫϥΠΞϯτ

    ʹυϝΠϯϞσϧΛఆٛ͢Δ • ⭕ ΫϥΠΞϯτଆ͚ͩͰӬଓԽΛߦ͏৔߹͸ɺΫϥΠΞϯτʹ υϝΠϯϞσϧΛఆٛ͢Δ 35
  36. ΫϥΠΞϯταΠυͷϞσϧ(2/2) • ! ෳࡶੑͷղܾͷͨΊʹΫϥΠΞϯτʹαʔόαΠυͷυϝΠ ϯϞσϧͷίϐʔ͕͍ͯ΋ྑ͍ʁ • ! αʔό͔Βड͚औͬͨσʔλΛϦϚοϓͯ͠ΫϥΠΞϯτଆ ʹओಋݖΛ࣋ͨͤΔઃܭͳΒυϝΠϯϞσϧΛΫϥΠΞϯτ͕ ࣮૷ͯ͠΋ྑ͍ʁ

    36
  37. ! ෳࡶੑͷղܾͷͨΊʹΫϥΠΞϯτʹ(αʔόαΠυͷίϐʔͷ) υϝΠϯϞσϧ͕͍ͯ΋ྑ͍ʁ 37

  38. (લఏ)֤αʔόαΠυͷίϯςΩετΛవΊͯѻ͏Ϋϥ ΠΞϯτ5 5 https://motida-japan.hatenablog.com/entry/2017/10/16/183508 38

  39. υϝΠϯϞσϧΛ࣋ͬͯ΋ྑ͍৔߹(1/2) ίϯςΩετͷ౷߹ΛΫϥΠΞϯτ಺Ͱߦ͏ 39

  40. υϝΠϯϞσϧΛ࣋ͬͯ΋ྑ͍৔߹(2/2) ΦϑϥΠϯͰ΋ಈ͘͜ͱΛอূ͢Δ 40

  41. υϝΠϯϞσϧΛ࣋ͨͳͯ͘΋ྑ͍৔߹ ΫϥΠΞϯτͰ͸ҰͭͷίϯςΩετ͔͠ѻΘͳ͍ 41

  42. ͜͜·Ͱͷ·ͱΊ • ΫϥΠΞϯτϓϩάϥϛϯά͸Ͳ͏ඳը͢Δ͔͕ओ໨త • ΫϥΠΞϯταΠυͰͷυϝΠϯϞσϧ͸ɺඞཁʹͳΔέʔε ͸έʔεόΠέʔε • ෳࡶͳ৔߹ = ෳ਺ͷίϯςΩετʹ·͕ͨΔΞϓϦέʔγϣϯ

    Λ࡞Δ৔߹ɺΫϥΠΞϯτʹ΋υϝΠϯϞσϧ͸͍ͯ΋ྑ͍(͍ Δ΂͖) 42
  43. શମͷ·ͱΊ • Ϟσϧ(ۀ຿)͸φϚϞϊɺมԽ͢ΔͷͰߟ͑ҭͯͯߦ͘ͷ͕େࣄ • αʔόɾΫϥΠΞϯτؔ܎ͳࣗ͘෼͕ͨͪܞΘΔۀ຿ʹؔ৺Λ ࣋ͪऔΓ૊Ή͜ͱͰɺΑΓྑ͍Ϟσϧ͕ੜ·ΕΔ 43

  44. Thanks 44

  45. SeeAlso • https://speakerdeck.com/j5ik2o/domeinqu-dong-she-ji-ji-chu- jiang-zuo-zhan-lue-bian • https://www.slideshare.net/hirokishigemura9/ruby-ddd • http://y-anz-m.blogspot.jp/2017/03/droidkaigi-2017_9.html • http://y-anz-m.blogspot.jp/2018/02/android.html

    45