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

SwiftでわかるSOLID原則 iOSDC 2020

k-kohey
September 21, 2020

SwiftでわかるSOLID原則 iOSDC 2020

iOSDC 2020の発表に用いた資料

k-kohey

September 21, 2020
Tweet

More Decks by k-kohey

Other Decks in Technology

Transcript

  1. ୯Ұ੹೚ͷݪଇʹैͬͯ੹຿Λ෼཭ͨ͠Ұྫ 6*7JFX$POUSPMMFS ભҠઌΛܾఆ͢Δॲཧ $PPSEJOBUPS ભҠΞχϝʔγϣϯ σβΠφʔ ભҠΞχϝʔγϣϯ ΛϦονʹʂ มߋΛཁٻ ϓϥϯφʔ

    ભҠॲཧΛҕৡ ભҠઌͷը໘Λ มߋ͍ͨ͠ʂ มߋΛཁٻ  $PPSEJOBUPSύλʔϯը໘ભҠʹؔ͢Δ੹຿Λ$PPSEJOBUPSͱݺ͹ΕΔΫϥε΁ҕৡ͢Δ࣮૷ύλʔϯ
  2. ୯Ұ੹೚ͷݪଇʹैͬͯ੹຿Λ෼཭ͨ͠Ұྫ 6*7JFX$POUSPMMFS ભҠઌΛܾఆ͢Δॲཧ $PPSEJOBUPS ભҠΞχϝʔγϣϯ σβΠφʔ ભҠΞχϝʔγϣϯ ΛϦονʹʂ มߋΛཁٻ ϓϥϯφʔ

    ભҠॲཧΛҕৡ ભҠઌͷը໘Λ มߋ͍ͨ͠ʂ มߋΛཁٻ  $PPSEJOBUPSύλʔϯը໘ભҠʹؔ͢Δ੹຿Λ$PPSEJOBUPSͱݺ͹ΕΔΫϥε΁ҕৡ͢Δ࣮૷ύλʔϯ
  3. ୯Ұ੹೚ͷݪଇʹैͬͯ੹຿Λ෼཭ͨ͠Ұྫ 6*7JFX$POUSPMMFS ભҠઌΛܾఆ͢Δॲཧ $PPSEJOBUPS ભҠΞχϝʔγϣϯ σβΠφʔ ભҠΞχϝʔγϣϯ ΛϦονʹʂ มߋΛཁٻ ϓϥϯφʔ

    ભҠॲཧΛҕৡ ભҠઌͷը໘Λ มߋ͍ͨ͠ʂ มߋΛཁٻ  $PPSEJOBUPSύλʔϯը໘ભҠʹؔ͢Δ੹຿Λ$PPSEJOBUPSͱݺ͹ΕΔΫϥε΁ҕৡ͢Δ࣮૷ύλʔϯ
  4. ୯Ұ੹೚ͷݪଇʹैͬͯ੹຿Λ෼཭ͨ͠Ұྫ 6*7JFX$POUSPMMFS ભҠઌΛܾఆ͢Δॲཧ $PPSEJOBUPS ભҠΞχϝʔγϣϯ σβΠφʔ ભҠΞχϝʔγϣϯ ΛϦονʹʂ มߋΛཁٻ ϓϥϯφʔ

    ભҠॲཧΛҕৡ ભҠઌͷը໘Λ มߋ͍ͨ͠ʂ มߋΛཁٻ 9$PPSEJOBUPSΛ༻͍ͨྫ IUUQTHJUIVCDPNRVJDLCJSETUVEJPT9$PPSEJOBUPS͔ΒҰ෦Ҿ༻ 
  5. ৼΔ෣͍·Ͱަ׵ՄೳʹͳΔ͜ͱ͸୲อ͞Εͳ͍ 6*4UBDL7JFXΛ༻͍ͨ൓ྫ )PHF7JFX 'VHB7JFX 6*7JFX pMM*ODMVEJOH#PSEFS 6*4UBDL7JFX ͜͜Ͱॲཧͷ෼ذ ͕ඞཁʹͳΔ 

    UIKit͸සൟʹมߋ͕ՃΘΒͳ͍ͨΊ͞΄Ͳ໰୊ʹͳΒͳ͍͕ αϒλΠϓΛ௥Ճ͢Δ౓ʹ ྫ֎ͷ֬ೝͱରԠΛ͢Δඞཁ͕͋Δͷ͸ ඇৗʹ໽հ
  6. ໊ࢦ͠ͷࢀরΛ࠷খݶʹ͢Δํ๏ ґଘੑ஫ೖΛ༻͍ͨࣄྫ w 4XJOKFDUͷΑ͏ͳґଘੑ஫ೖΛߦ͏࣮૷Λ༻͍Δ͜ͱʹΑͬͯɼ۩৅Ϋϥε ͷࢀরΛ࠷খݶʹͰ͖Δɽ ϓϩτίϧͱ ॳظԽʹඞཁͳ ύϥϝʔλ ۩৅Ϋϥεͷ Πϯελϯε

    ίϯςφʹ͋Δ 1FSTPOBMϓϩτίϧ ʹ४ڌͨ͠ΠϯελϯεΛԼ͍͞ 4VQFS1FSTPOͷΠϯελϯε ͕ొ࿥͞Ε͍ͯΔͷͰ ίϨΛ࢖͍ͬͯͩ͘͞ʂ  ຊൃදͰ͸ΠϯλϑΣʔεͱϓϩτίϧΛҙຯతʹ࢖Θ͚ͳ͍ɽͨͩ͠ɼϓϩτίϧͱ࢖͏ͱ͖͸ΑΓ4XJGUͷݴޠ࢓తͳഎܠ͕ڧ͍ɽ
  7. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 4XJGUͰΘ͔Δ40-*%ݪଇ!L@LPIFZJ w 40-*%ݪଇ w มߋʹڧ͘ཧղ͠΍͍͢γεςϜΛ࡞ΔͨΊʹ༗ӹ w ୯Ұ੹೚ͷݪଇ w ͋ΔΫϥε͸ͭͷΞΫλʔ܈ʹରͯ͠੹຿Λෛ͏΂͖Ͱ͋Δ

    w Ϧείϑͷஔ׵ݪଇ w ͋Δܕ"ͱަ׵Մೳͳܕ#Λ࢖༻Ͱ͖Δ৔߹ɼ#͸"ͱಉ͡ৼΔ෣͍Λ͢ Δ͜ͱΛอূ͞Εͳ͍ͱ͍͚ͳ͍ w ґଘੑٯసͷݪଇ w ந৅ʹґଘͤΑ w ͦͷଞͷݪଇ w ͕࣌ؒ଍ΓͣൃදͰ͖·ͤΜͰͨ͠ϒϩάʹ·ͱΊ·͢ɽ   5XJUUFSʢ!L@LPIFZJʣ ͜ͷࢿྉ͓Αͼ ΑΓৄࡉͳݪଇͷઆ໌ࢿྉ ΛπΠʔτ͍ͯ͠·͢
  8. ࢀߟจݙ ॻ੶ • <>3PCFSU$.BSUJOɼ੉୩ܒհɽΞδϟΠϧιϑτ΢ΣΞ։ൃͷԞٛୈ൛ΦϒδΣΫτࢦ޲։ൃͷਆ਷ͱঊͷٕʢʣ4#ΫϦΤΠ ςΟϒ • <>3PCFSU$.BSUJOɼ֯੐యɼߴ໦ਖ਼߂ɽ$MFBO"SDIJUFDUVSFୡਓʹֶͿιϑτ΢ΣΞͷߏ଄ͱઃܭʢʣ,"%0,"8" هࣄ • ΠϯλʔϑΣΠε෼཭ͷݪଇIUUQTUIJOLPOPCKFDUCMPHTQPUDPNJOUFSGBDFTFHSFHBUJPOQSJODJQMFJTQUPQIUNM

    • 40-*%ݪଇΛཧղ͢ΔIUUQTTIUOLHNDPNTPMJEIUNM • ΠϯλʔϑΣʔε෼཭ͷ๏ଇ *41 IUUQIBSVNJTBLVSBOFKQXPSEQSFTT &"&#&#'&#$&&"&#$&#& &#"&"&&#&JTQ • 4XJGUJ04ʹ͓͚Δ40-*%Š4JOHMF3FTQPOTJCJMJUZ1SJODJQMFIUUQTNFEJVNDPN!SJ[VNJUBTXJGU JPT&"#&"&&#TPMJETJOHMFSFTQPOTJCJMJUZQSJODJQMFBFBEEF • Α͘Θ͔Δ40-*%ݪଇ%ʢґଘੑٯసͷݪଇʣIUUQTOPUFDPNFSVLJUJOOFF • աڈʹ։࠵ͨ͠ňΞδϟΠϧιϑτ΢ΣΞ։ൃͷԞٛʼnͷษڧձʹͯ༻͍ΒΕͨࢿྉͨͪ ◦ IUUQTTQFBLFSEFDLDPNDIJHJDIBOBQQMJDBUJPOEFTJHONJBORJBOHIVJOVNCFS ◦ IUUQTTQFBLFSEFDLDPNL@LPIFZBQQMJDBUJPOEFTJHONJBORJBOHIVJOVNCFS