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

Clean ArchitectureとEffで変更に強いAPIを設計する

A967476c5855d593710a9a580f6b2aed?s=47 Yuichi Maekawa
September 25, 2020

Clean ArchitectureとEffで変更に強いAPIを設計する

A967476c5855d593710a9a580f6b2aed?s=128

Yuichi Maekawa

September 25, 2020
Tweet

More Decks by Yuichi Maekawa

Other Decks in Programming

Transcript

  1. $MFBO"SDIJUFDUVSFଚ&῎ଙ ኚ᭦䛻ᙉ䛔$3,䜢タィ䛩䜛 VFDODWRN\RRQOLQHYRO 6FDOD7RN\R .BFLBXB:VJDIJ

  2. .BFLBXB:VJDIJ 5XJUUFS!@LBFMBFMB 4PGUXBSF&OHJOFFS! ᪂᫬௦䛾㈍኎⟶⌮䝥䝷䝑䝖䝣䜷䞊䝮

  3. None
  4. $MFBO"SDIJUFDUVSFଚ&῎ୄ౶କ଑ો༷ፕଝჵ૶"1*ଠ᮱ᮣዷᔕଝଖ૶ଘ ଜ଎ᄰᮉଜଠ૽ ଛଠ଺૸ଝ౶૸ଠ૽ῷᑁᄾ᜷ଝᯝጓଉରଋ ᯌଇଜ૶ଅଚ  3&45"1*31$"1*ଠ"1*୷୦୔ணଠᯌଙଡଜ૶ଙଋQSBZ  $MFBO"SDIJUFDUVSFଠᯝጓ  ஒ୺୹ો&῎ଜଛଠዝ࿁᜷ଜᯝጓ

    ܶ᮱ᮣଚፘ૶ଘରଋ૾ો᮱ᮣଡୱ஬ஐଶஇ஝୰ୟ୸ଝ଺ଽଚᅈ૸ଠଙોᚨጤᘃଙ୒஛இ૾ᨭ૶ଚ᥻ૺଘ૶ଽ଴ଠଚ૶૸൩ቾଙૼᦎ૿ଁ଒ଇ૶ వጄଠങ࿧
  5. $MFBO"SDIJUFDUVSFଚ&῎ଙ ༷ፕଝჵ૶"1*ୄ᮱ᮣଋଽ

  6. ༷ፕଝჵ૶ଚଡ  ᳽඀ો༷ፕો൦Ḩ૾࿧ጕ  ༷ፕଝ଺ଽᄋẛ᡽ຸ૾ဌଇ૶  ល༢᜷ଜ༷ፕ૾ᱹ૿ଝଁ૶

  7. "1*ଡጄ૏ᇡ᷶ଋଽ  ୹஑୔ண஝୨୳ୟଠ༷ፕଝ଺ଽஜ୩஍ண୩ങ࿧ଠ༷ፕ  ஖஬୩ୡ஬୩ଠ༷ፕ  ዶଉ૶"1*ଠ᳽඀  "1*஁ங஑஬୯஬ଠ᳽඀ 

    ᨅ័୧୩୶ஐฎଃ"1*ଚ༻ᵄഏ᷻"1*  ᙊዷଠ఻ᑗ༷ፕଝౘ૸᳽ᄟ  ഏ᷻"1*ଠ୥஍஬୸᡽ຸሴག ଜଛଜଛ
  8. ༷ፕୄṟଉଁଋଽᮉິଡଖ ᴰଃଽଅଚଠଙ૿ଜ૶ᮉິ  ஃ୨୽୩஝୨୳ୟଠᇡ᷶ ፞ൖଠ୹஑୔ணஒ୷஛ଙଡ࿾ᄷଙ૿ଜ૶ ለᬾ஫᮱ᮣଝ଺ଽᮉິ  ୶୩୸૾ଜଁᄋẛ᡽ຸଠఒᕺ૾௧෺ᧄ  ಁྺዷฎଠၛ༢

    ୩஁ୢ୶୓  ௧ᴧ൐ଜ഼ṓႼ  གර૾ೇᜲ᜷ોᯬᚫ᜷ଜ഼ṓ ୱ஬ஐଶ࿚᭢᥽ଝ଺ଽ௹ᮓ᜷ଜ଴ଠ૾༾૶  Ḃᄮଠ൏Ṟ૾ଙ૿ଘ૶ଜ૶  ஃ୨୽୩ଚለᬾ  6*ଚ୷஬୯ᑑᴍ ଜଛ KWWSVFRPPRQVZLNLPHGLDRUJZLNL)LOH(GVJHUB:\EHB'LMNVWUDMSJ
  9. 3F༷ፕଝჵ૶ଚଡ  ᳽඀ો༷ፕો൦Ḩ૾࿧ጕ ༷ፕ࿧ጕᅌஃ୨୽୩஝୨୳ୟଠ༷ፕ ለᬾ஫᮱ᮣ  ༷ፕଝ଺ଽᄋẛ᡽ຸ૾ဌଇ૶ ༷ፕᵸஃ୨୽୩஝୨୳ୟଠ༷ፕለᬾ஫᮱ᮣ  ល༢᜷ଜ༷ፕ૾ᱹ૿ଝଁ૶

    ୹஑୔ணஒ୷஛ଠ࿍࿖ᅌଝ଺କଘᛛରାଽ இ஝ୠஙஎ૾౬ᛟଙ૿ଽଠଡለᬾ஫᮱ᮣଠᵄ൏
  10. ୒஛இଙଡ༷ፕଝჵ૶᮱ᮣୄ ଛ૸࿚ᚨଉଘ૶ଽଠ૽

  11. 4DBMFCBTF஀୳ୟ୘ண୹୧୩୶ஐ "QQMJDBUJPOGSBNFXPSL 4ZTUFN%FTJHO%PNBJOESJWFO%FTJHO 1PG&"" "SDIJUFDUVSF.PEVMFSNPOPMJUI $MFBO"SDIJUFDUVSF -JCSBSZ&῎ FF1PTUNBO

  12. 4DBMFCBTF஀୳ୟ୘ண୹୧୩୶ஐ "QQMJDBUJPOGSBNFXPSL 4ZTUFN%FTJHO%PNBJOESJWFO%FTJHO 1PG&"" "SDIJUFDUVSF.PEVMFSNPOPMJUI $MFBO"SDIJUFDUVSF -JCSBSZ&῎ FF1PTUNBO KWWSVVFDODPDWVXULRUJMDSURSRVDOV-

  13. 4DBMFCBTF஀୳ୟ୘ண୹୧୩୶ஐ "QQMJDBUJPOGSBNFXPSL 4ZTUFN%FTJHO%PNBJOESJWFO%FTJHO 1PG&"" "SDIJUFDUVSF.PEVMFSNPOPMJUI $MFBO"SDIJUFDUVSF -JCSBSZ&῎ FF1PTUNBO KWWSVVFDODPDWVXULRUJMDSURSRVDOV-

  14. 4DBMFCBTF஀୳ୟ୘ண୹୧୩୶ஐ "QQMJDBUJPOGSBNFXPSL 4ZTUFN%FTJHO%PNBJOESJWFO%FTJHO 1PG&"" "SDIJUFDUVSF.PEVMFSNPOPMJUI $MFBO"SDIJUFDUVSF -JCSBSZ&῎ FF1PTUNBO ଅଠᳬ૾ଛ૸୧୩୶ஐଝ࿪௨ଉଘ૶ଽ૽ଚ૶૸ᯌ

  15. $MFBO"SDIJUFDUVSFଙ ౧ୄᮛᓴଉ଑૶ଠ૽ KWWSVEORJFOHDQFRGHUFRPXQFOHEREWKHFOHDQDUFKLWHFWXUHKWPO

  16. $MFBO"SDIJUFDUVSFଙᜈᣨฅ஫Ἑ഼ṓႼଜୣ஬୹ପ ౫Ꮡ᪉ྥ䛾ᔂቯ౫Ꮡ᪉ྥ䜢୍᪉ྥ䛻䛩䜛 ୙㐺ษ䛺จ㞟ᗘ䝺䜲䝲䞊䛤䛸䛻౫Ꮡ䜢⤠䜛䚸䝴䞊䝇䜿䞊䝇䜢ศ㞳 㛵ᚰ䛾ศ㞳䝡䝆䝛䝇䝻䝆䝑䜽 䝗䝯䜲䞁 䛾ศ㞳䚸䜹䝥䝉䝹໬ Ļ 䝺䜲䝲䞊䛜ศ䛛䜜䚸␯⤖ྜ䞉㧗จ㞟ᗘ䛻䛺䛳䛯䝁䞊䝗䛿ኚ᭦䛜ᑠ䛥䛟䚸⡆༢䛻䛺䜛

  17. 4DBMFCBTFଡ௟ᨛ᜷ଜஜ୔ஔ஬୹୒஬ଢ଼୶ୟୱஓ $MFBO"SDIJUFDUVSFJO4DBMFCBTF #BUDI"EBQUFS )UUQ "EBQUFS &YUFSOBM)UUQ "EBQUFS %PNBJO 6TF$BTF 8FC6*

    %# 0UIFS $POUFYU (SQD "EBQUFS &OUJUZ-BZFS %PNBJOஒ୷஛ᥔ૿༂ૌಁྺଡଜଉ 6TF$BTF-BZFS ୒ୟ୯஬உ஬୩ଠ஖஬୩ୡ஬୩ *OUFSGBDF"EBQUFS-BZFS )UUQଡ"1*ᛟો4FDPVOEBSZଡ 3FQPTJUPSZᛟ(SQDଡങᵄᴉಘᛟ 'SBNFXPSLTBOE%SJWFST-BZFS %#ો୔ணஅஙો8FCଜଛଚᤳ૾ଽ 4FDPOEBSZ "EBQUFS
  18. 6TF$BTF*OUFSGBDF"EBQUFS૾ጤ᷾᜷഼ṓႼଝ଺଼᛽ଜଽඇ᎞ୄሿଖിᚫ૾ṓର଼ଶଋ૶ "1*ଠ༷ፕଡ$MFBO"SDIJUFDUVSFଠଛଅଙᱹଅଽଠ૽ #BUDI"EBQUFS )UUQ "EBQUFS &YUFSOBM)UUQ "EBQUFS %PNBJO 6TF$BTF 8FC6*

    %# 0UIFS $POUFYU (SQD "EBQUFS 6TF$BTF-BZFS ୒ୟ୯஬உ஬୩ଠ஖஬୩ୡ஬୩ *OUFSGBDF"EBQUFS-BZFS )UUQଡ"1*ᛟો4FDPVOEBSZଡ 3FQPTJUPSZᛟ(SQDଡങᵄᴉಘᛟ 4FDPOEBSZ "EBQUFS
  19. TCUଙ$MFBO"SDIJUFDUVSFଠස௟ಁྺዷฎᅌୄ࿚ᚨଋଽ TCUଠ.VMUJ1SPKFDUCVJMEଙୣண୶ଢ଼୩୸ ஜ୔ஔ஬ଙ൏൵ଉોಁྺዷฎୄᣪଽ *OUFSGBDF"EBQUFS6TF$BTF%PNBJO ໱፱᜷ଝଅା଒ଃଙ଺૶ ෝ࿬ଝ૶૸ଚ%*1 EFQFOEFODZJOWFSTJPOQSJODJQMF ଴ᬻକଘ૶ଽ

  20. 6TF$BTFଶ*OUFSGBDF"EBQUFS૽଻ለᬾ᜷ଜḂᄮୄ൏Ṟଙ૿ଘ૶ଽ૽ῷ 6TF$BTFଠിᚫ౺  ஒ୷஛ଠ$36%஫%#୒ୟ୫୩஫᛽ଜଽ୷஬୯୭஬୩อ൉஫"1*ୣ஬஛ଜଛ *OUFSGBDF"EBQUFSଠിᚫ౺  ᯔ᮸஫஖஬୩ୡ஬୩ଠ࿚ᬻ஫ஒ୷஛༷ኁ஫*0ଜଛ $MFBO"SDIJUFDUVSF଒ଃଙଡ࿏ഋଝ൏Ṟଙ૿ଜ૶ ଏଅଙ&῎

  21. &῎ଙ౧ୄᮛᓴଉ଑૶ଠ૽ KWWSRNPLMRUJIWS+DVNHOOH[WHQVLEOHPRUHSGI

  22. ᒶଛଠ୭அ୸ୖୗ୒ଡṻฉ፫ിᚫΰᇡൿཉዖ  )551சୟ୘୩୸  %#୒ୟ୫୩ ଜଛ 4DBMBଙଡ ṻฉ፫ിᚫ'VUVSFPSNPOJY5BTLଜଛ ᇡൿཉዖ5SZPS&JUIFS<- 3>ଜଛ

    ṻฉ፫ଠᣨ᎞ᇡൿཉዖ'VUVSF<&JUIFS<- 3>> ஒ୺୹ଠฅᇡ
  23. ஒ୺୹ଠฅᇡ૾ṟଉ૶ῷ

  24. GPSZJFMEუ GPS\ ଅଠ௴ଙଡଋଫଘNBQ ῐBU.BQ XJUI'JMUFS DBTFNBUDI JG ଠᢸᭅᑑዥ ໱፱᜷ଝଡ௟ଖଠୣண୶ଢ଼୩୸ଠ଱࿾ᰳ FY

    0QUJPO 'VUVSF &JUIFSଜଛ ଅଠ௴ଙለᬾ᜷ଜḂᄮଠ൲౬ᛟ૾இ஝ୠஙஐୄ᭲ṙଝଋଽ ൲౬ᛟ࠵ᙡᆨଠ༷ፕો*0ો౺༻ોFYFDVUJPODPOUFYUો4DIFEVMFSଜଛ ^ZJFME
  25. ஒ୺୹ฅᇡଠ๧Ẵ ೝ଻ଡଅାୄஒ୺୹୸ஙண୩அ୙஬எ஬ଙଡଜଁ&῎ଙᮛᓴଉଘ૶ଽ 'VUVSF<&SSPS&JUIFS6OJU>ୣண୶ଢ଼୩୸ &SSPS&JUIFS0QUJPO<.PEFM>ୣண୶ଢ଼୩୸

  26. &῎ &YUFOTJCMF&῎FDUT ᒩ឴ଝଡ&YUFOTJCMF&῎FDUTୄዋ๱ଉ଑.PSF&YUFOTJCMF&῎FDUTୄቫᛟ &῎௟ଖଠໜଙ᭲ዝଠඇ᎞ୄᭇᚨଙ૿ଽஒ୺୹ ଜ଎ᄰᮉଜଠ૽ ଺଼ለᬾ᜷ଜᵄ൏ଠḂᄮୄ൏Ṟଋଽ ૖4DBMBୄ౶૸࠵ஒ୺୹ୄ౶૸૗ *.0 ଚ૿ોฅᇡ૾ṟଉ૶ଚ૶૸ለᬾ᜷൝ᣇ ஒ୺୹ଠฅᇡୄ፞଴୧ணஇ஛ଝፘଃଽ

    அங୳୸ଙMJGU૾ଜ૶
  27. ୡ஬୩୩୯୷୓%SZ3VO ૴ଽ"1*ଙ୷஬୯ଠᓠ᣺ටୄଉଜ૶ଃଛᴉଽ૽ୱୗ୳ୟଋଽ

  28. ஖஬୩ୡ஬୩ଠ഼ṓႼ૾ጤ᷾᜷഼ṓ૽଻ᯬᚫ᜷഼ṓଝଜ଼ᅸᇸ ESZ3VOஅஙୠଙൗ࿖

  29. ଭମฉଊESZ3VO஖஬୩ୡ஬୩ୄ᳽඀ ࿚᭢ଡᑀ  ဌଇଜ஖஬୩ୡ஬୩ોဍଜ૶஖஬୩ୡ஬୩ଜଛଠ༂ฅଡᨭଇଏ૸  6TF$BTFଠᵶ᭲૾༗ૺଽஂக஬எண୘ங஬ଝ଺ଽ஀ୠୄᛛ଱ଶଋ૶  6TF$BTFଠಜᒩ૾႖ଝకನଝଜଽ༷ፕᵸୄ༗඀ଇ଍ଘଉର૸

  30. &῎ଙESZ3VOଠ*OUFSQSFUFSୄ౬ଽ 6TF$BTF-BZFS 3FBE8SJUFᛟଠ*OUFSQSFUFSଡଋଙଝ૴ଽ ࿚ᬻጤ SVO ଝଋଫଘ3PMMCBDLଋଽിᚫୄ᳽඀ଋଽଅଚଙ࿚ᚨଋଽ  6TF$BTFଠിᚫୄ௟൐༷ፕଉଜଁଘ଺૶  6TF$BTFങଝለᬾ᜷Ḃᄮଝ଺ଽ൏ဳଶ༷ኁ૾ଜଁଜଽ

  31. &῎ଙESZ3VOଠ*OUFSQSFUFSୄ౬ଽ *OUFSGBDF"EBQUFS-BZFS $POUSPMMFS1SFTFOUFSိଜଛଙ൏ဳിᚫୄፘ૿ESZ3VOଋଽଠ଱ ஖஬୩ୡ஬୩ଠၼଉ፝ૺଜଛଡଜଉ

  32. &῎ୄ౶૸஑ச୳୸  ஒ୺୹ଠฅᇡ૾ᢊසଝଜଽ  6TF$BTF*OUFSGBDF"EBQUFS૽଻ᒶଛଠለᬾ᜷Ḃᄮୄ൏Ṟଙ૿ોᨅᘑᮟᯘଠᭇᚨଝ᳴ଗଁ  ඇ᎞ୄ$POUFYU#PVOEଙᭇᚨଙ૿ો౧૾ᱹଅଽ૽ତଚ᝕ଙൗዴଙ૿ଽ %#୒ୟ୫୩૾ᱹଅ଼ᄠଽിᚫଜଠ଒ଜ ':*$POUFYU#PVOE EFGG<5>

     JNQMJDJUB"<5> EFGG<5">  ଚፘଃଽᢸᭅᑑዥ
  33. &῎ୄ౶૸୷஑ச୳୸  ᆰାଽରଙଝጤ᷾૾૽૽ଽῠೝଡགଉ଑୷஑ச୳୸ଙଡଜ૶ଚᅈ૸ῡ  ୣண஁୔஛୘ங஬ଝଡଜଽ૾ો୘ங஬૾ṟᮛ  ୒஬ଢ଼୶ୟୱஓଚଠᯌ૾ဍଜ૶  ဋഊఔ౺૾ဍଜ૶ 

    6TF$BTFଜଛୄ଺଼ᤅᾎଝ᮫᳻ଋଽ଑ଳଝଡഋଘଠိଙ&῎ୄᳵଋᄰᮉ૾૴ଽ
  34. ༷ፕᵸୄ௦଄ો༷ፕ࿧ጕᅌୄ௥଄ଽ଑ଳଝ$MFBO"SDIJUFDUVSFଚ&῎ୄ౶૸ $MFBO"SDIJUFDUVSF  ஒ୨க஬஛ටોස௟ಁྺዷฎୄ࿚ᚨଉોᜈᣨฅ஫Ἑ഼ṓႼଝଋଽ  TCUଠ.VMUJ1BDLBHFCVJMEଙᢊසଝ࿚ᚨଙ૿ଽ &῎  ஒ୺୹ଠฅᇡୄᢊසଝଋଽ 

    $MFBO"SDIJUFDUVSF଒ଃଙଡଙ૿ଜ૶ለᬾ᜷Ḃᄮଠ൏Ṟୄሟ૸ 5IBOLZPV