Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Clean Architecture

Clean Architecture

Takuma Shimizu

August 01, 2018
Tweet

More Decks by Takuma Shimizu

Other Decks in Programming

Transcript

  1. ΫϦʔϯΞʔΩςΫ
    νϟࣄ࢝Ί
    ٕज़ษڧձ

    View full-size slide

  2. ΞϓϦ෦େࡕ՝
    ਗ਼ਫ୓ຏ
    !IPLVSPO
    J04
    3VCZPO3BJMT

    View full-size slide

  3. ΫϦʔϯΞʔΩςΫ
    νϟࣄ࢝Ί
    ٕज़ษڧձ

    View full-size slide

  4. ͜ͷൃදʹ͍ͭͯ
    w ͜·Ίʹ࣭໰Λड͚෇͚·͢
    w ๨Ε͍ͯͨΒࢦఠ͍ͯͩ͘͠͞!
    w ͦΕҎ֎Ͱ΋్தͰ࣭໰͕͋Ε͹ԿͳΓͱ
    w $MFBO"SDIJUFDUVSFຊ ݪஶɾ຋༁
    Λݩʹߏ੒
    w ΫϦʔϯΞʔΩςΫνϟͷ؊ͱͳΔ෦෼Λநग़

    View full-size slide

  5. ΫϦʔϯΞʔΩςΫ
    νϟ׬શʹཧղͨ͠
    ໨ඪ 15&

    View full-size slide

  6. ໨ඪ ݠḮ

    ΫϦʔϯΞʔΩςΫ
    νϟͳΜ͔෼͔Δ

    View full-size slide

  7. ΫϦʔϯΞʔΩςΫνϟͷ؊
    ޡղू
    ॻ੶঺հ
    ͓஌Βͤ

    View full-size slide

  8. ΫϦʔϯΞʔΩςΫνϟͷ؊

    View full-size slide

  9. ࢀরɿIUUQTUIMJHIUDPNCMPHVODMFCPCUIFDMFBOBSDIJUFDUVSFIUNM

    View full-size slide

  10. w ʮΫϦʔϯΞʔΩςΫνϟʯͱ͍͏ΞʔΩςΫνϟ͸ͳ͍
    w ΑΓྑ͍ ΫϦʔϯͳ
    ΞʔΩςΫνϟΛࢦ֓͢೦
    w ஶऀͷ3PCFSU$.BSUJOʹΑΔz$MFBOzγϦʔζͷҰͭ
    w $MFBO$PEF
    w $MFBO$PEFS
    w $MFBO"SDIJUFDUVSF

    View full-size slide

  11. ࢀরɿIUUQTUIMJHIUDPNCMPHVODMFCPCUIFDMFBOBSDIJUFDUVSFIUNM

    View full-size slide

  12. ΫϦʔϯΞʔΩςΫνϟͷ؊
    w #VTJOFTT3VMFT
    w &OUJUZ
    w 6TF$BTF
    w ґଘํ޲
    w *OUFSGBDF"EBQUFST

    View full-size slide

  13. #VTJOFTT3VMFT

    View full-size slide

  14. &OUJUZ
    w $SJUJDBMCVTJOFTTSVMF
    w ׬શʹಠཱ
    w υϝΠϯۦಈઃܭͷυϝΠϯϞσϧ
    w &OUJUZ 3FGFSFODF
    PCKFDUɼ7BMVFPCKFDUɼ4FSWJDF
    w ʰΦϒδΣΫτࢦ޲ιϑτ΢ΣΞ޻ֶ004&ʱ಺ͷ༻ޠ

    View full-size slide

  15. 6TF$BTF
    w "QQMJDBUJPOTQFDJpDCVTJOFTTSVMF
    w 6* %# ϑϨʔϜϫʔΫͷӨڹ͸ड͚ͳ͍
    w ΞϓϦӡ༻ͷมߋͷӨڹ͸ड͚Δ
    w &OUJUZʢυϝΠϯϞσϧʣͷΫϥΠΞϯτ

    View full-size slide

  16. #VTJOFTT3VMFT
    w$SJUJDBMCVTJOFTTSVMF
    w"QQMJDBUJPOTQFDJpDCVTJOFTTSVMF
    རӹ૿Ճɺඅ༻࡟ݮʹؔΘΔϧʔϧ΍खଓ͖

    View full-size slide

  17. $SJUJDBMWT"QQTQFDJpD
    &OUJUZWT6TF$BTF

    w $SJUJDBMखಈͰ΋࣮ߦՄೳ
    w "QQTQFDࣗಈԽ͞Ε͍ͯΔ͜ͱ͕લఏ
    w $SJUJDBMγεςϜ͔Β͸ಠཱ
    w "QQTQFDγεςϜʹґଘ

    View full-size slide

  18. l$SJUJDBMz#VTJOFTT3VMF
    ˣ
    l&OUFSQSJTFz#VTJOFTT3VMF

    View full-size slide

  19. l&OUFSQSJTFz#VTJOFTT3VMF
    #$ΞϓϦͰ͸ʜ
    w ར༻ऀ͸ෆಛఆଟ਺ͷҰൠϢʔβʔ
    w ൃ஫ݩͷച্΍རӹɺۀ຿ʹ௚઀ӨڹΛ༩͑ͳ͍
    w ͦΖ͹ΜΛ஄͘Α͏ͳखଓ͖͕ଘࡏ͠ͳ͍
    ˠ$SJUJDBM͸"QQMJDBUJPOTQFDJpDͱಉٛʁ

    View full-size slide

  20. $SJUJDBMͱ"QQTQFDͷҧ͍
    w γεςϜ͔Βೖग़ྗͱͷڑ཭ͷҧ͍
    w มߋස౓ͱมߋཧ༝ͷҧ͍
    w ୯Ұ੹೚ͷݪଇ 4JOHMF3FTQPOTJCJMJUZ1SJODJQMF

    View full-size slide

  21. ೖग़ྗͷڑ཭
    w ʮ-FWFMʯͱ͍͏֓೦
    w Ϣʔβʔ΍γεςϜͷೖྗͱग़ྗ͔Β཭Ε͍ͯΔ΄Ͳ

    -FWFM͕ߴ͍
    w -FWFM͕ҟͳΕ͹มߋස౓ɾཧ༝΋ҟͳΔ
    w &OUJUZ͔6TF$BTFͰ໎ͬͨΒz-FWFMzΛൺֱ
    w ΑΓ-FWFM͕ߴ͍΄͏Λ&OUJUZʹ෼཭
    w ୯Ұ੹೚ͷݪଇΛద༻͍ͯ͠Ε͹෼཭͸ΑΓ؆୯ʹͳΔ

    View full-size slide

  22. #VTJOFTT3VMFTͷ·ͱΊ
    w &OUJUZ $SJUJDBM
    ͱ6TF$BTF "QQMJDBUJPOTQFDJpD

    w $SJUJDBM͸γεςϜʹґΒͣɺ"QQTQFD͸γεςϜ͋Γ͖
    w &OUJUZ͸׬શʹಠཱ͠ɺ6TF$BTF͸ͦͷΫϥΠΞϯτ
    w -FWFMͷܭଌͰᐆດ͞ճආ
    w #VTJOFTT3VMFʹ͚ͩͰͳ͘Ͳ͜Ͱ΋ద༻Մೳ

    View full-size slide

  23. ґଘํ޲
    w ৗʹҰํ޲ʹ͚ͩʹґଘ
    w ґଘؔ܎ٯసͷݪଇ %FQFOEFODZJOWFSTJPOQSJODJQMF

    w ೖग़ྗσʔλ΁ͷґଘ੍໿

    View full-size slide

  24. Ұํ޲΁ͷґଘ
    w ͜ͷ෦෼
    w ԼҐ-FWFMͷϨΠϠʔ ίϯϙʔωϯτ
    ͸

    ্Ґ-FWFMͷϨΠϠʔ ίϯϙʔωϯτ
    ʹґଘ͢Δ
    w ্Ґ-FWFM͸ɺԼҐ-FWFMͰ࢖༻͞Ε͍ͯΔ໊લΛ

    ར༻ͯ͠͸͍͚ͳ͍
    w ܕ໊ɺϝιουɺϓϩύςΟͳͲ
    w ্Ґ-FWFM͸ɺԼҐ-FWFMͰ࢖༻͞Ε͍ͯΔσʔλߏ଄Λ

    ར༻ͯ͠͸͍͚ͳ͍

    View full-size slide

  25. ґଘؔ܎ٯసͷݪଇ
    w ͜ͷ෦෼

    View full-size slide

  26. 6TF$BTF
    $POUSPMMFS
    1SFTFOUFS

    View full-size slide

  27. 6TF$BTF
    $POUSPMMFS
    1SFTFOUFS

    View full-size slide

  28. 6TF$BTF
    $POUSPMMFS
    1SFTFOUFS

    View full-size slide

  29. 6TF$BTF
    1SFTFOUFS

    View full-size slide

  30. 6TF$BTF
    1SFTFOUFS

    View full-size slide

  31. 6TF$BTF
    1SFTFOUFS

    View full-size slide

  32. 6TF$BTF
    1SFTFOUFS
    0VUQVU
    *OUFSGBDF

    View full-size slide

  33. 6TF$BTF
    1SFTFOUFS
    0VUQVU
    *OUFSGBDF

    View full-size slide

  34. 6TF$BTF
    1SFTFOUFS
    0VUQVU
    *OUFSGBDF
    6TF$BTF
    1SFTFOUFS

    View full-size slide

  35. ґଘؔ܎ٯసͷݪଇ
    w্Ґ-FWFMͷϨΠϠʔ ίϯϙʔωϯτ
    ͕

    ԼҐ-FWFMͷϨΠϠʔʹґଘ͢ΔͷΛ๷͙
    w *OUFSGBDFQSPUPDPMΛؒʹڬΜͰ্Ґ-FWFMଆʹ഑ஔ
    w *OUFSGBDF"EBQUFST

    View full-size slide

  36. ೖग़ྗσʔλ΁ͷґଘ੍໿
    w ୯७ͳσʔλߏ଄ମ
    w ݴޠ૊ΈࠐΈͷϓϨʔϯͳΦϒδΣΫτͰߏ੒
    w ࣗଞͷϨΠϠʔಠࣗͷΦϒδΣΫτ͸ؚΊͳ͍
    w σʔλߏ଄ମ΋Ұͭͷґଘ෺
    w ্Ґ-FWFM͸ɺԼҐ-FWFMͷσʔλߏ଄ମΛ஌Βͳ͍

    View full-size slide

  37. ґଘํ޲ͷ·ͱΊ
    w ؔ৺ͷ෼཭
    w ґଘํ޲͸ৗʹҰఆ
    w ԼҐ-FWFM͸্Ґ-FWFMʹґଘ$ٯ͸ېࢭ%
    w ϨΠϠʔͷؒΛ·͕ͨΔσʔλߏ଄ʹ΋ద༻͞ΕΔ
    w ্Ґ͕ԼҐʹґଘ͢Δ৔߹͸ґଘؔ܎ٯసͷݪଇ

    View full-size slide

  38. ΫϦʔϯΞʔΩςΫνϟͷ؊
    w &OUJUZ $SJUJDBM#VTJOFTT3VMF

    w 6TF$BTF "QQMJDBUJPOTQFDJpD#VTJOFTT3VMF

    w l-FWFMz
    w ґଘํ޲ɺґଘؔ܎ٯసͷݪଇ

    View full-size slide

  39. ؊ͷ֎ଆ
    & &

    View full-size slide

  40. w *OUFSGBDF"EBQUFS
    w .7$ .77. .71 .717.FUD
    w 42- 3&45"1* (SBQI2-FUD
    w 'SBNFXPSL %SJWFS
    w J04 "OESPJE 8FC .BSJB%# 'JSFCBTFFUD

    View full-size slide

  41. ΫϦʔϯΞʔΩςΫνϟͷ؊ͷ

    ֎ଆͷ؊
    w ࠾༻͢Δઃܭύλʔϯ΍σʔλϕʔεͳͲͷܾఆΛ୨্͛
    w ΑΓ಺ଆͷ։ൃʹूதͰ͖Δ
    w ຊ౰ͷҙຯͰ֎ଆΛҙࣝ͠ͳ͍ͰࡁΉ

    View full-size slide

  42. ΫϦʔϯΞʔΩςΫνϟͷ؊
    w &OUJUZ $SJUJDBM#VTJOFTT3VMF

    w 6TF$BTF "QQMJDBUJPOTQFDJpD#VTJOFTT3VMF

    w l-FWFMz
    w ґଘํ޲ɺґଘؔ܎ٯసͷݪଇ

    View full-size slide

  43. ޡղͦͷ̍
    5SBOTMBUPS͸ඞਢ

    View full-size slide

  44. ޡղͦͷ̍
    5SBOTMBUPS͸ඞਢ
    ౴͑
    ෆཁ

    View full-size slide

  45. ޡղͦͷ
    3FQPTJUPSZͱ
    %BUB4UPSF͸ηοτ

    View full-size slide

  46. ޡղͦͷ
    3FQPTJUPSZͱ
    %BUB4UPSF͸ηοτ
    ౴͑
    ෆཁ

    View full-size slide

  47. ޡղͦͷ
    .71ύλʔϯΛ࢖͏

    View full-size slide

  48. ޡղͦͷ
    .71ύλʔϯΛ࢖͏
    ౴͑
    ԿͰ΋͍͍

    View full-size slide

  49. ޡղͦͷ
    &OUJUZ͸%%%Ͱઃܭ

    View full-size slide

  50. ޡղͦͷ
    &OUJUZ͸%%%Ͱઃܭ
    ౴͑
    ԿͰ΋͍͍

    View full-size slide

  51. ޡղͦͷ
    ϨΠϠʔΛ·͙ͨͱ͖
    ʹ3FBDUJWF&YUFOTJPOT
    ศར͡ΌͶʁ

    View full-size slide

  52. ޡղͦͷ
    ϨΠϠʔΛ·͙ͨͱ͖ʹ
    3FBDUJWF&YUFOTJPOTศར͡Ό
    Ͷʁ
    ౴͑
    ΍Ίͯ

    View full-size slide

  53. ޡղͦͷ
    ΍Δ͜ͱଟ͘ͳ͔ͬ͢Ͷ

    View full-size slide

  54. ޡղͦͷ
    ΍Δ͜ͱଟ͘ͳ͔ͬ͢Ͷ
    ౴͑
    ͦͷͱ͓ΓɻͰ΋
    ίʔυϦʔσΟϯά
    ͷෛՙ͸Լ͕Δ

    View full-size slide

  55. ޡղͦͷ
    ॳݟࡴͩ͠ΑͶʁ

    View full-size slide

  56. ౴͑
    ॳݟࡴͩ͠ΑͶʁ
    ͏Μɺ
    ͔ͩΒࠓઆ໌ͯ͠Δ

    View full-size slide

  57. ΫϦʔϯΞʔΩςΫ
    νϟ׬શʹཧղͨ͠
    ໨ඪ 15&

    View full-size slide

  58. ໨ඪ ݠḮ

    ΫϦʔϯΞʔΩςΫ
    νϟͳΜ͔෼͔Δ

    View full-size slide

  59. ޡ ਖ਼
    5SBOTMBUPS͸ඞਢ ෆཁ
    3FQPTJUPSZͱ
    %BUB4UPSF͸ηοτ
    ෆཁ
    .71ύλʔϯΛ࢖͏ ͳΜͰ΋͍͍
    &OUJUZ͸%%%Ͱઃܭ ͳΜͰ΋͍͍
    ϨΠϠʔΛ·͙ͨͱ͖ʹ3FBDUJWF&YUFOTJPOศ
    ར͡ΌͶʁ
    ΍Ίͯ
    ΍Δ͜ͱଟ͘ͳ͔ͬ͢Ͷ
    Ӿཡ࣮૷
    ͳΒ΍ΔՁ஋͋Γ

    View full-size slide

  60. ॻ੶঺հ ݪஶ

    Robert C. Martin,

    Clean Architecture:
    A Craftsman's Guide
    to Software
    Structure and
    Design

    View full-size slide

  61. ॻ੶঺հ ຋༁

    ϩόʔτɾ$Ϛʔνϯ

    ʰ$MFBO"SDIJUFDUVSFɹ
    ୡਓʹֶͿιϑτ΢ΣΞ
    ͷߏ଄ͱઃܭʱ

    ʢ֯੐యɾߴ໦ਖ਼߂༁ʣ

    View full-size slide

  62. ॻ੶঺հ ͦͷଞ

    ϰΝʔϯɾϰΝʔϊϯ

    ʰ࣮ફυϝΠϯۦಈઃ
    ܭʱʢߴ໦ਖ਼߂༁ʣ

    View full-size slide

  63. ॻ੶঺հ ͦͷଞ

    ΤϦοΫɾΤϰΝϯε

    ʰΤϦοΫɾΤϰΝϯε
    ͷυϝΠϯۦಈઃܭʱ

    ʢࠓؔ߶؂म 

    ɹ࿨ஐӈܡɾ຀໺༞ࢠ
    ༁ʣ

    View full-size slide