Slide 1

Slide 1 text

(Pݴޠ5*14Ћ 5PNPLJ0UB /Pd/P 1

Slide 2

Slide 2 text

5*1 γϟυʔΠϯά 2

Slide 3

Slide 3 text

γϟυʔΠϯάͱ͸ʁ ҟͳΔείʔϓͰಉ໊͡લͷม਺͕࢖༻͞Ε ͨͱ͖ʹɺҟͳΔม਺ͱͯ͠ѻΘΕΔ͜ͱɻ 3

Slide 4

Slide 4 text

(PͰ͸࠶એݴ͸ίϯύΠϧΤϥʔ ಉ͡είʔϓ಺ ࠶એݴ https://go.dev/play/p/77k9VUeMwps 4

Slide 5

Slide 5 text

ಉ͡είʔϓ಺ ࠶એݴ ྫ֎ https://go.dev/play/p/irqsWg06HT1 a͸࠶୅ೖɺb͸࠶એݴʹͳΔ 5

Slide 6

Slide 6 text

ҟͳΔείʔϓ γϟυʔΠϯά είʔϓ͕ҟͳΔͱɺม਺໊͕ҰॹͰ΋ҧ͏ม਺ͱͯ͠ѻΘΕΔ https://go.dev/play/p/w7gbbczDzSX 6

Slide 7

Slide 7 text

είʔϓͱ͸ԿͰ͠ΐ͏ʁ 2VJ[̍ 7

Slide 8

Slide 8 text

JGͳͲ\^Ͱ۠੾ΒΕͨΒ είʔϓ͕มΘΔ ❌ 8

Slide 9

Slide 9 text

Ͱ͸ɺϒϩοΫͱ͸ʁ 2VJ[ 9

Slide 10

Slide 10 text

ϒϩοΫ㱠είʔϓ 10

Slide 11

Slide 11 text

ϒϩοΫͱ͸ʁ ιʔείʔυͷʮ͔ͨ·Γʯͷ͜ͱɻ ݫີʹ͍͏ͱεςʔτϝϯτ܈ɻۭͰ΋༗ޮɻ FH\^Ͱғ·ΕͨྖҬ 11

Slide 12

Slide 12 text

ϒϩοΫͷछྨ w ໌ࣔతϒϩοΫ\^Ͱғ·Εͨεςʔτϝϯτ܈ w ҉໧తϒϩοΫ VOJWFSTFશͯͷ(Pͷιʔείʔυͷ֎ଆΛแΉϒϩ οΫ QBDLBHFύοέʔδશମΛแΉϒϩοΫ fi MFϑΝΠϧͷϒϩοΫ *G GPS TXJUDIϒϩοΫ TXJUDI TFMFDUʹ͓͚ΔઅϒϩοΫ 12

Slide 13

Slide 13 text

FHGPSϒϩοΫ https://go.dev/play/p/2FGM_uX1kZb GPSd^͕ϒϩοΫ \d^͸ϒϩοΫͰ͸ͳ͍ 13

Slide 14

Slide 14 text

TXJUDI TFMFDUʹ͓͚ΔઅϒϩοΫ https://go.dev/play/p/dH3q4JG4HUj 14

Slide 15

Slide 15 text

είʔϓͱ͸ʁ ࣝผࢠ YͳͲ ͷએݴ͕ٴͿൣғ 15

Slide 16

Slide 16 text

είʔϓWTϒϩοΫ ϒϩοΫ: ιʔείʔυͷࣈ۟తɾ৔ॴతͳ෺ཧ ૚ʹ͍ۙϨΠϠʔͷ࿩ είʔϓ : ࣝผࢠͷએݴͷ಺༰·Ͱ౿ΈࠐΜͰߟ ͑ΔߴϨΠϠʔͷ࿩ 16

Slide 17

Slide 17 text

γϟυʔΠϯά άϩʔόϧม਺ͷ৔߹ 17

Slide 18

Slide 18 text

γϟυʔΠϯά https://go.dev/play/p/Wh04ZwS7HH4 18 O FSSͷܗʹؾΛ෇͚Δ O FSSʹ͢ΔͱΤϥʔ͕ग़ͯ͠·͏ ͷͰɺ஌Β͵·ʹʹͯ͠γϟυ΢Πϯά ͯ͠͠·͏͜ͱ͕ଟ͍

Slide 19

Slide 19 text

γϟυʔΠϯά https://go.dev/play/p/Wh04ZwS7HH4 19 γϟυ΢Πϯάͨ͘͠ͳ͍ͱ͖͸ FSSΛલ΋ͬͯએݴ͢Δ

Slide 20

Slide 20 text

ಉ͡είʔϓ಺ ࠶એݴ ࠶ܝ https://go.dev/play/p/irqsWg06HT1 a͸࠶୅ೖɺb͸࠶એݴʹͳΔ aͷܕ͕ҧ͏ͱΤϥʔ err͸࠶୅ೖ 20

Slide 21

Slide 21 text

γϟυʔΠϯά ϦϯλʔΛ࢖ͬͯγϟυʔΠϯάΛ ݕ஌͢Δ͜ͱ͸Մೳ ઃఆ͕ඞཁ TIBEPXΛ࢖͏ 21

Slide 22

Slide 22 text

5*1 ϝϯλϧίʔυϞσϧͷܗ੒ 22

Slide 23

Slide 23 text

ϝϯλϧίʔυϞσϧͷܗ੒ w ωετͤ͞ͳ͍ɹˠૣظSFUVSOͰฦ͢ w ϋοϐʔύεΛࠨଆͰἧ͑Δ FMTF͸࢖Θͳ͍ w ϊϯϋοϐʔύε͸৚݅Λ൓సͯ͠ɺϋοϐʔ ύεʹ͢Δ Մಡੑͷ͍͍ίʔυΛॻ͚ͬͯ͜ͱ 23

Slide 24

Slide 24 text

ϝϯλϧίʔυϞσϧͷྫ 24

Slide 25

Slide 25 text

5*1 JOJUؔ਺ 25

Slide 26

Slide 26 text

JOJUؔ਺ͱ͸ʁ ΞϓϦέʔγϣϯͷঢ়ଶΛॳظԽ ͢ΔͨΊʹ༻͍ΒΕΔؔ਺ɻ Ҿ਺ΛऔΒͣɺԿ΋஋Λฦ͞ͳ͍ɻ 26

Slide 27

Slide 27 text

JOJUؔ਺ͷ࣮ߦλΠϛϯά ύοέʔδ಺ͷ શͯͷఆ਺ͱม਺એݴͷධՁ ύοέʔδ͕ॳظԽ JOJUؔ਺ͷ࣮ߦ https://go.dev/play/p/d0CtZAhTRhF 27

Slide 28

Slide 28 text

NBJO͕ผύοέʔδʹґଘ͢Δͱ͖ main͔Βfooͷfunc()ΛݺͿͱ͖ͷ࣮ߦॱ 28

Slide 29

Slide 29 text

ύοέʔδ಺ʹෳ਺ͷJOJUؔ਺͕͋Δ৔߹ ϑΝΠϧͷΞϧϑΝϕοτॱʹ࣮ߦ͞ΕΔɻ BHPͷJOJU ˠCHPͷJOJU ˠDHPͷJOJU 29

Slide 30

Slide 30 text

ύοέʔδ಺ʹෳ਺ͷJOJUؔ਺͕͋Δ৔߹ ϑΝΠϧ໊Λม͑ͨͱ͖ʹ࣮ߦॱ͕มߋ͞ΕΔՄೳੑ͕͋Δɻ JOJU ͷॱ൪ʹґଘͯ͠͸͍͚ͳ͍ɻ 30

Slide 31

Slide 31 text

෭࡞༻ͷͨΊͷJOJU ଞύοέʔδͷJOJU ͚ͩΛ࣮ߦ͍ͨ͠৔߹ JNQPSUͰϒϥϯΫࣝผࢠ@Λ͚ͭΔɻ 31

Slide 32

Slide 32 text

෭࡞༻ͷͨΊͷJOJU NBJOؔ਺ͷதͰJOJUؔ਺͸࣮ߦͰ͖ͳ͍ɻ 32

Slide 33

Slide 33 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ σʔλϕʔεͷίωΫγϣϯϓʔϧͷอ࣋ σʔλϕʔεΛΦʔϓϯͯ͠ 1JOH͕Ͱ͖Δ͔֬ೝ͠ άϩʔόϧม਺ʹ୅ೖ͍ͯ͠Δɻ 33

Slide 34

Slide 34 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ JOJUؔ਺͕ΤϥʔΛฦ͞ͳ͍ 34

Slide 35

Slide 35 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ JOJUؔ਺͕ΤϥʔΛฦ͞ͳ͍ ˠΤϥʔΛ௨஌͢Δखஈ͸ύχοΫΛى͜͠ɺ ΞϓϦέʔγϣϯΛఀࢭ͢Δ͜ͱ 35

Slide 36

Slide 36 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ JOJUؔ਺͕ΤϥʔΛฦ͞ͳ͍ ˠΤϥʔΛ௨஌͢Δखஈ͸ύχοΫΛى͜͠ɺ ΞϓϦέʔγϣϯΛఀࢭ͢Δ͜ͱ ˠݺͼग़͠ݩͰϦτϥΠ΍ϑΥʔϧόοΫ͕ Ͱ͖ͳ͘ͳΔ 36

Slide 37

Slide 37 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ ςετέʔεΛ࣮ߦ͢Δલʹ JOJU͕࣮ߦ͞ΕΔ 37

Slide 38

Slide 38 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ ςετέʔεΛ࣮ߦ͢Δલʹ JOJU͕࣮ߦ͞ΕΔ ˠ%#΁ͷίωΫγϣϯΛ࡞੒͢Δඞཁ͕ͳ͍ ϢʔςΟϦςΟؔ਺ʹର͢Δ୯ମςετͳͲͷ ςετ͕ॻ͖ʹ͘͘ͳΔ 38

Slide 39

Slide 39 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ ໰୊ σʔλϕʔεͷίωΫγϣϯϓʔϧΛ άϩʔόϧม਺ʹ୅ೖ͢Δඞཁ͕͋Δ ˠͲͷؔ਺͔ΒͰ΋ύοέʔδ಺ͷάϩʔ όϧม਺ΛมߋͰ͖ͯ͠·͏ ˠάϩʔόϧม਺ʹґଘ͢Δؔ਺͸੾Γ཭ ͞Ε ͳ͍ͷͰɺ୯ମςετ͕ෳࡶʹͳΔՄೳੑ͕ ͋Δ 39

Slide 40

Slide 40 text

JOJU Λ࢖΂͖Ͱ͸ͳ͍ͱ͖ 40

Slide 41

Slide 41 text

JOJU Λ࢖ͬͯ΋͍͍ͱ͖ JOJU͕ࣦഊ͢Δ͜ͱ͸ͳ͍ άϩʔόϧม਺Λ࡞Δඞཁ͕ͳ͍ ୯ମςετʹӨڹΛ༩͑Δ͜ͱ͕ͳ͍ 41

Slide 42

Slide 42 text

JOJU Λ࢖ͬͯ΋͍͍ͱ͖ JOJU͕ࣦഊ͢Δ͜ͱ͸ͳ͍ άϩʔόϧม਺Λ࡞Δඞཁ͕ͳ͍ ୯ମςετʹӨڹΛ༩͑Δ͜ͱ͕ͳ͍ 42

Slide 43

Slide 43 text

JOJU Λ࢖ͬͯ΋͍͍ͱ͖ JOJU͕ࣦഊ͢Δ͜ͱ͸ͳ͍ IBOEMFS͕OJMͰ͸ͳ͍ͷͰɺύχ οΫʹͳΒͳ͍ άϩʔόϧม਺Λ࡞Δඞཁ͕ͳ͍ ୯ମςετʹӨڹΛ༩͑Δ͜ͱ͕ ͳ͍ GoͷެࣜϒϩάͰ͸੩తͳHTTPઃఆΛ ߦ͏ͨΊʹinitؔ਺Λ࢖༻͍ͯ͠Δɻ 43

Slide 44

Slide 44 text

5*1 HFUUFSͱTFUUFSͷ࢖͍ํ 44

Slide 45

Slide 45 text

ͳͥHFUUFSͱTFUUFSΛ࢖͏ͷ͔ʁ HFUUFS TFUUFS͸ΧϓηϧԽΛ ࣮ݱ͢ΔͨΊʹ͋Δɻ 45

Slide 46

Slide 46 text

ΧϓηϧԽͱ͸ʁ ΦϒδΣΫτͷ஋΍ঢ়ଶΛӅ͢͜ͱ 46

Slide 47

Slide 47 text

(Pʹ͓͚ΔHFUUFSTFUUFS (Pʹ͸ࣗಈͰHFUUFSTFUUFSΛ࡞੒͢Δػೳ͸ͳ͍ɻ 1ZUIPO!QSPQFSUZ +BWB!%BUB MPNCPL (P-BOEʹ͸͋ΔΒ͍͠😆 47

Slide 48

Slide 48 text

ΧϓηϧԽͷྫ UJNF5JNFSߏ଄ମ͸ɺ͍͔ͭ͘ͷϑΟʔϧυʹ௚઀ΞΫηεͰ͖Δߏ଄ମΛ ࣮૷͢Δ https://pkg.go.dev/time#Timer 48

Slide 49

Slide 49 text

ΧϓηϧԽͷྫ ඇਪ঑͕ͩɺ$Λ௚઀मਖ਼͢Δ͜ͱ΋Ͱ͖Δɻ ͨͩ͠ɺΠϕϯτΛड͚औΕͳ͘ͳΔ 49

Slide 50

Slide 50 text

HFUUFSTFUUFSͷϝϦοτ w ϑΟʔϧυͷऔಘ΍ઃఆʹؔ͢Δಈ࡞ΛΧϓηϧԽ͠ɺޙ͔Β ৽ͨͳػೳΛ௥ՃͰ͖ΔΑ͏ʹ͢Δɻ ϑΟʔϧυΛݕূͨ͠ ΓɺܭࢉʹΑΔ஋Λฦͨ͠ΓɺϑΟʔϧυ΁ͷΞΫηεΛϛϡ ʔςοΫεͰอޢͨ͠Γͱ͍ͬͨػೳ w ಺෦දݱΛӅṭ͢Δ͜ͱͰެ։͢Δ΋ͷΛॊೈʹมߋͰ͖Δɻ w ࣮ߦ࣌ʹϓϩύςΟ͕มߋ͞Εͨ৔߹ͷσόοά༻ϒϨΠΫϙ ΠϯτΛఏڙ͠ɺσόοάΛ༰қʹ͢Δɻ 50

Slide 51

Slide 51 text

HFUUFSTFUUFSΛ࢖͏ͱ͖ લํޓ׵ੑΛอূ͢ΔϢʔε έʔεͷՄೳੑ͕༧૝͞ΕΔ ͱ͖ʹ༗ޮ 51

Slide 52

Slide 52 text

HFUUFSTFUUFSΛ࢖͏ͱ͖ w HFUUFSϝιουͷ໊લ͸#BMBODFʹ͢Δ ❌(FU#BMBODF w TFUUFSϝιουͷ໊લ͸4FU#BMBODFʹ͢Δ ߏ଄ମͷHFUUFS TFUUFS͕ԿͷՁ஋΋ͳ͍ͷͰ͋Ε͹࢖͏΂͖Ͱ͸ͳ͍ɻ 52

Slide 53

Slide 53 text

HFUUFSTFUUFS͕͍ͬͺ͍🤮🤮🤮 53

Slide 54

Slide 54 text

5FMM %POU"TL ਘͶΔͳɺ໋͡Α ΧϓηϧԽͱ͸ɺgetter/setterΛ࣮૷͢Δ͜ͱͰ͋Δͱ͍ͬͨઆ໌͕౓ʑݟड͚ΒΕ·͢ɻ·ͨɺ։ൃπ ʔϧʹ͸getter/setterΛࣗಈ࣮૷͢ΔΧϓηϧԽͱݺ͹ΕΔػೳ͕͋Γ·͢ɻ͜ΕΒ͸ΧϓηϧԽͰ͸ͳ ͍ͱɺචऀ͸ओு͠·͢ɻgetter/setterΛ༰қ͢Δͱ஋Λউखʹग़͠ೖΕՄೳʹͳΓɺෆਖ਼஋ͷࠞೖ΍ॏ ෳίʔυͳͲɺ௿ڽूͷѱຐ͕ͨͪ๫Εग़͠·͢ɻ͘͠Έ͸ɺԿΒ͔ͷ໰୊Λղܾ͢ΔͨΊʹଘࡏ͠· ͢ɻ͔͠͠ɺgetter/setter͸ղܾͲ͜Ζ͔໰୊ͷݪҼʹͳ͍ͬͯ·͢ɻ ΧϓηϧԽͱ͸σʔλͱͦͷσʔλΛૢ࡞͢ΔϩδοΫΛ1ͭͷΫϥεʹ·ͱΊɺඞཁͳखଓ͖ͷΈΛ֎ ෦΁ެ։͢Δ͜ͱͰ͢ɻΧϓηϧԽʹΑΓ௿ڽूߏ଄Λ཈ࢭͰ͖·͢ɻෆਖ਼ঢ়ଶ͔Β๭ද͢ΔόϦσʔ γϣϯϩδοΫͳͲΛΧϓηϧԽ͢Δ͜ͱͰ҆શͳΠϯελϯεʹͳΓ·͢ɻ By ϛϊۦಈ ྑ͍ίʔυѱ͍ίʔυͰֶͿઃܭೖ໳ ্ख͘ΧϓηϧԽͰ͖ͳ͍ཧ༝ Ϋιίʔυಈը 54

Slide 55

Slide 55 text

HFUUFSTFUUFS͸ѱ͔ʁ TFUUFS͸ѱ HFUUFS͸࣌ͱ৔߹ʹΑΔ ʲೖ໳ʳ݁ہgetter/setter͸ѱͳͷ͔ ΋͏GetterʗSetterΛ࢖͏ͷ͸΍ΊΑ͏ʢfeat. cleanCodeʣ ࢀߟจݙ 55

Slide 56

Slide 56 text

TFUUFS࢖ΘͣʹͲ͏͢Δʁ ίϯετϥΫλΛ࢖͑ 56

Slide 57

Slide 57 text

TFUUFS࢖ΘͣʹͲ͏͢Δʁ ίϯετϥΫλΛ࢖͑ (PʹίϯετϥΫλ͸ͳ͍ ❌ 57

Slide 58

Slide 58 text

TFUUFS࢖ΘͣʹͲ͏͢Δʁ ίϯετϥΫλΛ࢖͑ (PʹίϯετϥΫλ͸ͳ͍ ❌ ϑΝΫτϦؔ਺Λ࢖͏ 58

Slide 59

Slide 59 text

ϑΝΫτϦؔ਺ γϯϓϧͳྫ 59

Slide 60

Slide 60 text

ϑΝΫτϦؔ਺ γϯϓϧͳྫ 60

Slide 61

Slide 61 text

ϑΝΫτϦؔ਺ γϯϓϧͳྫ ϙΠϯλΛฦͯ͠΋͍͍ 61

Slide 62

Slide 62 text

5*1 ΠϯλʔϑΣΠε 62

Slide 63

Slide 63 text

ΠϯλʔϑΣΠεͱ͸ʁ 2VJ[ 63

Slide 64

Slide 64 text

ΠϯλʔϑΣΠεͱ͸ʁ JOUFSGBDF͸(P΍+BWBʹ͸͋Δ͕ɺ1ZUIPOͳͲʹ ͸ଘࡏ͠ͳ͍ɻ ݴޠʹΑͬͯ͸ɺQSPUPDPMɺUSBJU ͱ΋ݺ͹ΕΔɻ 64

Slide 65

Slide 65 text

ΠϯλʔϑΣΠεͱ͸ʁ ΦϒδΣΫτͷৼΔ෣͍Λࢦఆ͢Δํ๏Λఏڙ͢ Δɻෳ਺ͷΦϒδΣΫτ͕࣮૷Ͱ͖Δڞ௨ͷந৅Խ Λ࡞੒͢ΔͨΊʹ࢖͏ɻ Goݴޠ100Tips 65

Slide 66

Slide 66 text

ΠϯλʔϑΣΠεͱ͸ʁ ΦϒδΣΫτͷૢ࡞ͷ໊લͱܕͷू·Γ 66

Slide 67

Slide 67 text

(PͷJOUFSGBDFWT+BWBͷJOUFSGBDF Ұ൪ͷҧ͍͸JNQMFNFOUTΛ໌͍ࣔͯ͠Δ͔Ͳ ͏͔ɻ+BWB͸JNQMFNFOUTΛ໌ࣔ͢Δɻ(P͸҉ ໧తʹJOUFSGBDFΛ࢖༻͢Δɻ 67

Slide 68

Slide 68 text

(PͷJOUFSGBDFWT+BWBͷJOUFSGBDF (P +BWB 68

Slide 69

Slide 69 text

(PͷJOUFSGBDFWT+BWBͷJOUFSGBDF (P +BWB 69

Slide 70

Slide 70 text

(PͷJOUFSGBDFWT+BWBͷJOUFSGBDF +BWBͰ͸*OUFSGBDFࣗ਎͕جఈ ͷܕͷΑ͏ʹѻΘΕΔ͜ͱͰͲ ͷΑ͏ͳΫϥεͰ͋Δ͔Λදݱ ͢Δɻ ˠJOUFSGBDFΛॻ͘͜ͱΛਪ঑ ͞ΕΔ (PͷJOUFSGBDF͸ຬͨ͢΂͖ৼ Δ෣͍Λఆٛ͠ɺͦͷৼΔ෣͍ Λຬ͔ͨ͢Ͳ͏͔Ͱ੍໿Λදݱ ͢Δɻ TUBUJDͳμοΫλΠϐϯ ά ˠա৒ʹ࢖͏ͷ͸ྑ͘ͳ͍ 70

Slide 71

Slide 71 text

(PͷJOUFSGBDFͷࢥ૝ wந৅Խ͸࡞੒͢Δ΋ͷͰ͸ͳ͘ɺ ൃݟ͢Δ΋ͷ w࠷ॳ͔Βந৅ԽΛͯ͠͸͍͚ͳ͍ ˠඞཁʹͳͬͨΒ࡞੒͢Δ 71

Slide 72

Slide 72 text

(PͷJOUFSGBDFͷࢥ૝ “Don’t design with interfaces, discover them.” By Rob Pike ΠϯλʔϑΣΠεͰઃܭ͢ΔͷͰ͸ͳ͘ɺΠ ϯλʔϑΣΠεΛൃݟ͢Δɻ 72

Slide 73

Slide 73 text

(PͷJOUFSGBDFͷ஫ҙ ΠϯλʔϑΣΠεΛհͯ͠ɺϝιουΛݺͼग़͢ͱɺੑೳ্ͷ Φʔόϔου͕ൃੜ͢Δ͜ͱ΋͋ΔɻΠϯλʔϑΣΠε͕ࢦ͢ ۩৅ܕΛݟ͚ͭΔͨΊʹɺϋογϡςʔϒϧͷσʔλߏ଄Λݕ ࡧ͢Δඞཁ͕͋Δɻͨͩ͠ɺͦͷݕࡧͷΦʔόϔου͸࠷খͳ ͷͰɺଟ͘ͷঢ়گͰ໰୊ʹͳΔ͜ͱ͸ͳ͍ɻ ࢀߟ : GoͷInterfaceʹ͍ͭͯ 73

Slide 74

Slide 74 text

JOUFSGBDFΛ࢖͏͜ͱͷϝϦοτ w࣮૷ͷ੾Γସ͕͑ՄೳͱͳΔ wςετ͕༰қʹͳΔ wଟॏܧঝ͕Ͱ͖Δ 74

Slide 75

Slide 75 text

JOUFSGBDFΛ࢖͏͜ͱͷσϝϦοτ w৑௕ʹͳΔՄೳੑ͕͋Δ wਓʹΑͬͯ͸शಘ͕೉͍͠ 75

Slide 76

Slide 76 text

JOUFSGBDF io.Writer io.Reader ιʔε͔ΒσʔλΛಡΈࠐΉ λʔήοτ΁σʔλΛॻ͖ࠐΉ 76

Slide 77

Slide 77 text

JOUFSGBDFͷྫ 77

Slide 78

Slide 78 text

JOUFSGBDFͷྫ ϑΝΠϧͷ಺༰ΛผͷϑΝΠϧʹίϐʔ͢Δؔ਺ Encrypt 78

Slide 79

Slide 79 text

JOUFSGBDFͷྫ ϑΝΠϧͷ಺༰ΛผͷϑΝΠϧʹίϐʔ͢Δؔ਺ Encrypt 79

Slide 80

Slide 80 text

2VJ[ ࣮ࡍʹจࣈΛbase64ʹΤϯίʔυ͢ΔϓϩάϥϜΛ ࡞੒ͯ͠Έ͍ͯͩ͘͞ɻ 80

Slide 81

Slide 81 text

JOUFSGBDFΛ࢖Θͳ͍ྫ ҉߸ԽϓϩάϥϜ console͔Βͷඪ४ग़ྗΛ҉߸Խ͢ΔϓϩάϥϜ 81

Slide 82

Slide 82 text

JOUFSGBDFΛ࢖Θͳ͍ྫ ҉߸ԽϓϩάϥϜ ϑΝΠϧΛ҉߸Խ͢ΔϓϩάϥϜ SFBE#ZUF͕SFBE'JMF XSJUF#ZUF͕XSJUF'JMFʹͳͬͨͷͰ FODSZQU ࣗମ΋मਖ਼͕ඞཁ 82

Slide 83

Slide 83 text

ํ਑ͱϨϕϧ ༨ஊ ιϑτ΢ΣΞγεςϜํ਑Λࣔͨ͠΋ͷ ίϯϐϡʔλϓϩάϥϜೖྗΛग़ྗʹม׵͢Δํ਑Λৄࡉʹهड़ͨ͠΋ͷ ґଘੑͷํ޲͸઀ଓ͢ΔίϯϙʔωϯτͷϨϕϧͰܾ·ΔɻৗʹɺԼҐϨϕϧͷίϯϙʔωϯτ ্͕ҐϨϕϧͷίϯϙʔωϯτʹґଘ͢ΔΑ͏ʹઃܭ͢Δɻ 83

Slide 84

Slide 84 text

ํ਑ͱϨϕϧ ༨ஊ Ϩϕϧೖྗͱग़ྗ͔Βͷڑ཭ɻ ํ਑͕γεςϜͷೖྗͱग़ྗ͔Β཭Ε͍ͯΕ͹ɺϨϕϧ͸ߴ͘ͳ Δɻೖྗͱग़ྗΛ؅ཧ͢Δํ਑͕γεςϜͷதͰ࠷ԼҐϨϕϧͷ ํ਑ɻ 84

Slide 85

Slide 85 text

ํ਑ͱϨϕϧ ༨ஊ σʔλϑϩʔͱιʔείʔυͷ ґଘੑ͸ɺඞͣ͠΋ಉ͡ํ޲ͱ ͸ݶΒͳ͍ɻιʔείʔυͷґ ଘੑ͸σʔλϑϩʔ͔Β੾Γ཭ ͠ɺϨϕϧͱ݁ͼ͚ͭΔ΂͖Ͱ ͋Δɻ 85

Slide 86

Slide 86 text

JOUFSGBDFΛ࢖ͬͨྫ ҉߸ԽϓϩάϥϜ console͔Βͷඪ४ग़ྗΛ҉߸Խ͢ΔϓϩάϥϜ ґଘؔ܎ͷ޲͖Λinterfaceʹ޲͚Δ 86

Slide 87

Slide 87 text

JOUFSGBDFΛ࢖ͬͨྫ ҉߸ԽϓϩάϥϜ console͔Βͷඪ४ग़ྗΛ҉߸Խ͢ΔϓϩάϥϜ https://go.dev/play/p/2g5dkUlu90a 87

Slide 88

Slide 88 text

JOUFSGBDFΛ࢖ͬͨྫ ҉߸ԽϓϩάϥϜ File͔Βͷඪ४ग़ྗΛ҉߸Խ͢ΔϓϩάϥϜ 88

Slide 89

Slide 89 text

ํ਑ͱϨϕϧ ༨ஊ σʔλϑϩʔͱιʔείʔυͷ ґଘੑ͸ɺඞͣ͠΋ಉ͡ํ޲ͱ ͸ݶΒͳ͍ɻιʔείʔυͷґ ଘੑ͸σʔλϑϩʔ͔Β੾Γ཭ ͠ɺϨϕϧͱ݁ͼ͚ͭΔ΂͖Ͱ ͋Δɻ 89

Slide 90

Slide 90 text

(PͷJOUFSGBDFͷࢥ૝ “The bigger the interface, the weaker the abstraction.” By Rob Pike ΠϯλʔϑΣΠε͕େ͖͚Ε͹େ͖͍΄Ͳ ந৅Խ͸ऑ͘ͳΔ 90

Slide 91

Slide 91 text

JOUFSGBDFͷFNCFEEJOH JOUFSGBDFʹJOUFSGBDFΛFNCFE ͬͪ͜ͷํ͕ ݟ΍͍͢ʂ *ͱ+͕ඃΔͱ Τϥʔ 91

Slide 92

Slide 92 text

JOUFSGBDFͷ&NCFEEJOH 3FBE8SJUFͷྫ JOUFSGBDFʹJOUFSGBDFΛFNCFE 92

Slide 93

Slide 93 text

JOUFSGBDFͷ&NCFEEJOH 4USVDUʹJOUFSGBDFΛFNCFE 93

Slide 94

Slide 94 text

TUSVDUͷ&NCFEEJOH 4USVDUʹTUSVDUΛFNCFE 94

Slide 95

Slide 95 text

(Pͷ&NCFEEJOH w&NCFEEJOH͸ܧঝͰ͸ͳ͍ ҕৡ w਌ͷܕͷม਺ʹ೿ੜܕͷ஋͸୅ೖͰ͖ͳ͍ wΦʔόϥΠυ͍ͯ͠ΔͷͰ͸ͳ͘ɺશ͘ಉ͡ϑΟʔϧυΛ ௥Ճ͍ͯ͠Δ͚ͩ 95 (P͸७ਮͳ00ݴޠͰ͸ͳ͍

Slide 96

Slide 96 text

ܧঝΑΓҕৡ͕͍͍ཧ༝ ΦʔόϥΠυ͍ͯ͠ͳ͍ͷͰ ݩͷIPHFͷಈ࡞͸มΘΒͳ͍ #ͷIPHF ͱ"ͷIPHF ͭଘࡏ͢Δ ΋͠ΦʔόϥΠυͯ͠͠·͏ͱ ୯Ұ੹೚ͷݪଇʹ൓͢Δ৔߹ ॊೈʹมߋ͕Ͱ͖ͳ͍ 96

Slide 97

Slide 97 text

(Pͷ&NCFEEJOH ਌ʹࢠΛ୅ೖ͠Α͏ͱ͢Δͱ ίϯύΠϧΤϥʔʹͳΓ·͢ɻ 97

Slide 98

Slide 98 text

(Pͷ&NCFEEJOH ༨ஊ 98 ʮ਌Λࢠʹ୅ೖʯ͸Τϥʔʹ ͳΓ·ͤΜɻͳͥͰ͠ΐ͏ɻ

Slide 99

Slide 99 text

(Pͷ&NCFEEJOH ༨ஊ 99 "θϩ஋͕ઃఆ͞ΕΔ͔Βɻ ࠨଆͷ࣮ߦ݁Ռ͸zzͳͷͰɺԿ΋ද ࣔ͞Εͳ͍ https://go.dev/play/p/v9RV7aE99UH

Slide 100

Slide 100 text

JOUFSGBDFͷద੾ͳཻ౓ ࡉ͔͘͢Ε͹͢Δ΄Ͳɺ࠶ར༻ͷϨϕϧ͕ߴ͘ͳΓڧྗͳந৅ԽͱͳΔɻ ͔͠͠ɺࡉ͔͗ͯ͘͢͠΋͍͚ͳ͍ɻ 100

Slide 101

Slide 101 text

JOUFSGBDF͍ͭ࢖͏ʁ wڞ௨ͷৼΔ෣͍ w۩ମతͳ࣮૷ͱͷ෼཭ wৼΔ෣͍ͷ੍ݶ 101

Slide 102

Slide 102 text

ڞ௨ͷৼΔ෣͍ TPSUύοέʔδͷJOUFSGBDF ιʔτͷʮฒ΂Δʯͱ͍͏ৼΔ෣͍Λந৅Խ͢Δ ιʔτͷछྨ͸ؾʹ͠ͳ͍ 102

Slide 103

Slide 103 text

ڞ௨ͷৼΔ෣͍ TPSUύοέʔδͷJOUFSGBDF 103

Slide 104

Slide 104 text

۩ମతͳ࣮૷ͷ෼཭ ίʔυΛ۩ମతͳ࣮૷͔Β੾Γ཭͢ ந৅Խ͞ΕͨΠϯλʔϑΣΠεʹґଘ͞ ͤΔ͜ͱͰ۩ମͷ੾Γସ͑Λ༰қʹ͢Δ Ϧείϑͷஔ׵ݪଇ 104

Slide 105

Slide 105 text

Ϧείϑͷஔ׵ݪଇ -41 -JTLPW4VCTUJUVUJPO1SJODJQMF φ(x) Λܕ T ͷΦϒδΣΫτ x ʹؔͯ͠ূ໌Մೳͳੑ࣭ͱ͢Δɻ͜ͷͱ͖ɺП(y) ͸ ܕ T ͷαϒλΠϓ S ͷΦϒδΣΫτ y ʹ͍ͭͯਅͰͳ͚Ε͹ͳΒͳ͍ɻ B. Liskov and J. WingɺA Behavioral Notion of Subtyping 105

Slide 106

Slide 106 text

Ϧείϑͷஔ׵ݪଇ -41 -JTLPW4VCTUJUVUJPO1SJODJQMF ʮαϒλΠϓʯͷΦϒδΣΫτ͸ผͷܕʢʮεʔύʔλΠϓʯʣͷΦϒδΣΫτͷ ͢΂ͯͷৼΔ෣͍ͱɺߋʹผͷԿ͔Λඋ͑ͨ΋ͷͰ͋Δɻ ͜͜Ͱඞཁͱ͞ΕΔ΋ ͷ͸ɺҎԼʹࣔ͢ஔ׵ͷੑ࣭ͷΑ͏ͳ΋ͷͩΖ͏ɿܕ S ͷ֤ΦϒδΣΫτ o1 ʹର ͠ɺܕTͷΦϒδΣΫτ o2 ͕ଘࡏ͠ɺT ʹؔͯ͠ఆٛ͞Εͨ͢΂ͯͷϓϩάϥϜ P ͕ o1 Λ o2 Ͱஔ͖׵͑ͯ΋ಈ࡞Λม͑ͳ͍৔߹ɺS ͸ T ͷαϒλΠϓͰ͋Δ B. LiskovɺData Abstraction and HierarchyɺLiskov 1988, p. 25, 3.3. Type Hierarchy 106

Slide 107

Slide 107 text

αϒλΠϓ ೿ੜܕ ͱ͸ʁ αϒλΠϓ 4VCUZQF ͱ͸ɺJTBͷؔ܎ʹ͋Δ΋ͷɻ ΄ͱΜͲͷαϒλΠϓ͸4VCTUJUVBCMJUZ ަ׵Մೳੑ Λ࣋ ͭɻ ͭ·ΓɺαϒλΠϓ ೿ੜܕ ʹґଘͯ͠͸͍͚ͳ͍ɻ αϒλΠϓ͸ɺ೿ੜ΋ͱͷํʹஔ׵ՄೳͰͳ͚Ε͹ ͳΒͳ͍ɻ 107

Slide 108

Slide 108 text

Ϧείϑͷஔ׵ݪଇͷྫ int <: double (intܕ͸doubleܕͷ೿ੜܕ)ͷͱ ͖ɺintܕͷΦϒδΣΫτTΛdobuleܕʹஔ׵ ͯ͠΋Կ΋໰୊͕ͳ͍͕ɺdoubleܕΛintܕͱ Έͳ͢ͷ͸ةݥɻ 108

Slide 109

Slide 109 text

Ϧείϑͷஔ׵ݪଇͷྫ int <: double (intܕ͸doubleܕͷ೿ੜܕ)ͷͱ ͖ɺintܕͷΦϒδΣΫτTΛdobuleܕʹஔ׵ ͯ͠΋Կ΋໰୊͕ͳ͍͕ɺdoubleܕΛintܕͱ Έͳ͢ͷ͸ةݥɻ 109

Slide 110

Slide 110 text

෼཭Ͱ͖͍ͯͳ͍ྫ ۩ମతͳ࣮૷ʹ ґଘ͢Δ ݁߹ςετͰ MySQLΛىಈ͢Δ ඞཁ͕͋Δ 110

Slide 111

Slide 111 text

۩ମతͳ࣮૷ͷ෼཭ 111 ετϨʔδͷந৅Խ

Slide 112

Slide 112 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 112 ্ҐϨϕϧͷํ਑ͷ࣮૷ίʔυ͸ɺԼҐϨϕϧ ͷৄࡉͷ࣮૷ίʔυʹґଘ͢΂͖Ͱ͸ͳ͘ɺٯʹ ৄࡉଆ͕ํ਑ʹґଘ͢΂͖Ͱ͋Δͱ͍͏ݪଇɻ

Slide 113

Slide 113 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 113 ࠷΋ॊೈͳγεςϜιʔείʔυͷґଘؔ܎͕ந ৅͚ͩΛࢀর͍ͯ͠Δ ˠ۩৅ʹґଘͯ͠͸͍͚ͳ͍ɻ ˠந৅Ϋϥε΍ΠϯλʔϑΣΠεʹґଘ͢Δ

Slide 114

Slide 114 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 114 (PͰ͸1ZUIPOͷΫϥεͷΑ ͏ʹɺந৅ϝιουͱ۩৅ϝ ιουΛͻͱͭͷTUSVDUͷத ʹఆٛ͢Δ͜ͱ͕Ͱ͖ͳ͍ ˠJOUFSGBDFΛ࢖͏

Slide 115

Slide 115 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 115 ۩৅ʹઈରґଘͤͯ͞͸͍͚ͳ͍Θ͚Ͱ͸ͳ͍

Slide 116

Slide 116 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 116 ۩৅ʹઈରґଘͤͯ͞͸͍͚ͳ͍Θ͚Ͱ͸ͳ͍ มԽ͠΍͍͢۩৅ʹ͸ґଘͯ͠͸͍͚ͳ͍ ։ൃதͷϞδϡʔϧ΍සൟʹมߋ͞Εଓ͚͍ͯΔϞδϡʔϧͳͲ

Slide 117

Slide 117 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 117 DMBTT"͕DMBTT#ʹґଘ͍ͯ͠Δ

Slide 118

Slide 118 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 118 #ͷJOUFSGBDFΛ࡞Γɺ" #ͷґଘํ޲Λ#ͷJOUFSGBDFʹ޲͚Δ

Slide 119

Slide 119 text

ґଘؔ܎ٯసͷݪଇ %*1 %FQFOEFODZ*OWFSTJPO1SJODJQMF 119 Ϋϥε"#ͷJOUFSGBDFΛ"ͱΈͳ͢͜ͱͰ #Λ"ʹґଘͤ͞Δ͜ͱ͕Ͱ͖Δɻ

Slide 120

Slide 120 text

ґଘੑͷ஫ೖ %* 120 ͯ͞ӈͷίʔυͷTVN ͸Ͳ͏΍ͬͯ ςετ͢ΔͰ͠ΐ͏͔ʁ https://go.dev/play/p/f458gJyZBdg

Slide 121

Slide 121 text

ґଘੑͷ஫ೖ %* 121 IPHF ͱGPP ͷฦ͢஋͕มΘͬͨΒ௵Ε·͢ TVN͕IPHF ͱGPP Λ஌͍ͬͯΔ͔ΒͰ͖Δςετ

Slide 122

Slide 122 text

ґଘੑͷ஫ೖ %* 122 ͪ͜Βͷςετ΋TVN͕IPHF ͱGPP Λ஌͍ͬͯ Δඞཁ͕͋Δɻ IPHF͕௵ΕΔͱ͜ͷςετ΋ࣦഊ͢Δ

Slide 123

Slide 123 text

ґଘੑͷ஫ೖ %* 123 ࠶એݴͳͷͰίϯύΠϧΤϥʔ

Slide 124

Slide 124 text

ґଘੑͷ஫ೖ %* 124 ࠨͷΑ͏ʹίʔυΛमਖ਼ͨ͠ΒͲ͏Ͱ͠ΐ͏͔ʁ

Slide 125

Slide 125 text

ґଘੑͷ஫ೖ %* 125 Ҿ਺ʹ͢Δ͜ͱͰTVN͸IPHF ͱGPP Λ஌Βͳ͘ ͯ΋ςετ͢Δ͜ͱ͕Ͱ͖Δ ͜ΕΛґଘੑͷ஫ೖͱ͍͏ɻ

Slide 126

Slide 126 text

ґଘੑͷ஫ೖ %* 126 repositoryʹґଘ͍ͯ͠Δ

Slide 127

Slide 127 text

ґଘੑͷ஫ೖ %* 127 repositoryʹґଘ͍ͯ͠Δ

Slide 128

Slide 128 text

ґଘੑͷ஫ೖ %* SFQPTJUPSZΛ஫ೖ͍ͯ͠Δ

Slide 129

Slide 129 text

ґଘੑͷ஫ೖ %*

Slide 130

Slide 130 text

͓·͚%*ίϯςφ TFSWJDFʹEPHͱDBUΛ஫ೖ͍ͯ͠Δ HPPHMFXJSFͷྫ

Slide 131

Slide 131 text

͓·͚%*ίϯςφ ࣗಈੜ੒ mainؔ਺ %*ίϯςφ͸஫ೖ͢ΔҾ਺͕ଟ͍࣌ʹศར HPPHMFXJSFͷྫ

Slide 132

Slide 132 text

ΠϯλʔϑΣΠεϑΝΫτϦ 5JQTͷϑΝΫτϦؔ਺ γϯϓϧͳྫ ͷଓ͖ ϙΠϯλΛฦ͢ͷ͕׳ྫత 132

Slide 133

Slide 133 text

ΠϯλʔϑΣΠεϑΝΫτϦ 5JQTͷϑΝΫτϦؔ਺ γϯϓϧͳྫ ͷଓ͖ 133

Slide 134

Slide 134 text

ΠϯλʔϑΣΠεϑΝΫτϦ RunͷςετΛ ͍ͨ͠ ൃలฤVTFDBTFͷςετ 134

Slide 135

Slide 135 text

ΠϯλʔϑΣΠεϑΝΫτϦ ςετγφϦΦ mockͨ͠repositoryͰusecase ͷΠϯελϯεΛ࡞੒ Assert RepositoryΛmockͯ͠ɺಠࣗͷrepositoryʹஔ͖׵͑Δ 135

Slide 136

Slide 136 text

ৼΔ෣͍ͷ੍ݶ ಈతͳઃఆΛѻ͏ͨΊʹΧελϜઃ ఆύοέʔδΛ࣮૷͢Δɻ ͜͜Ͱɺઃఆ஋Λऔಘ͠ɺߋ৽ͨ͠ ͘ͳ͍ͱ͢ΔɻಡΈऔΓઐ༻Ͱ͋Δ ͜ͱΛڧ੍͍ͨ͠ɻ 136

Slide 137

Slide 137 text

ৼΔ෣͍ͷ੍ݶ ಈతͳઃఆΛѻ͏ͨΊʹΧελϜઃ ఆύοέʔδΛ࣮૷͢Δɻ ͜͜Ͱɺઃఆ஋Λऔಘ͠ɺߋ৽ͨ͠ ͘ͳ͍ͱ͢ΔɻಡΈऔΓઐ༻Ͱ͋Δ ͜ͱΛڧ੍͍ͨ͠ɻ ઃఆ஋ͷऔಘ͚ͩʹৼΔ෣͍Λ ੍ݶ͢Δந৅ԽΛߦ͏ 137

Slide 138

Slide 138 text

ৼΔ෣͍ͷ੍ݶ JOU$PO fi H(FUUFS͸ɺ/FX'PPϑΝΫ τϦؔ਺ʹ஫ೖ͞Ε͍ͯΔɻ JOU$PO fi Hߏ଄ମ͸JOU$PO fi H(FUUFSΛ ࣮૷͍ͯ͠ΔͷͰɺ/FX'PPϑΝΫτ Ϧؔ਺ͷҾ਺ͱͯ͠౉͢͜ͱ͕Ͱ͖ɺ /FX'PPؔ਺ͷΫϥΠΞϯτʹ͸Өڹ Λ༩͑ͳ͍ɻ #BS͸ઃఆ஋ͷऔಘͷΈͰɺߋ৽͸Ͱ ͖ͳ͍ɻ 138

Slide 139

Slide 139 text

ৼΔ෣͍ͷ੍ݶ P.69࠶ܝ 139

Slide 140

Slide 140 text

2VJ[ μοΫλΠϐϯάͱ͸ʁ 140

Slide 141

Slide 141 text

μοΫλΠϐϯάͱ͸ʁ If it walks like a duck and quacks like a duck, it must be a duck. by Dave Thomas ΋͠΋ͦΕ͕ΞώϧͷΑ͏ʹา͖ɺΞώϧͷΑ͏ʹ໐͘ͷͳΒɺͦΕ͸Ξώϧʹҧ͍ͳ͍ 141

Slide 142

Slide 142 text

μοΫλΠϐϯάͱ͸ʁ μοΫλΠϐϯάͱ͸ಈతܕ෇͚ݴޠͰ༻͍ΒΕΔ ܕ෇͚ͷελΠϧͰɺ FH3VCZ 1ZUIPO 142

Slide 143

Slide 143 text

μοΫλΠϐϯάͷϝϦοτ w μοΫλΠϐϯά͸ݺͼग़͢ϝιου͑͞Λ͍࣋ͬͯΕ͹ ͍͍ͷͰݺͼग़͠ଆ͸ܕͳͲͷલఏ஌ࣝ͸ෆཁͰ͋Δɻ w ॊೈੑɾ֦ுੑ͕ߴ͘ͳΔ w ґଘ͕গͳ͘ͳΔ 143

Slide 144

Slide 144 text

μοΫλΠϐϯάͷσϝϦοτ w ܕͷ੔߹ੑʹΑΔΤϥʔ͕ى͖΍͘͢ͳΓɺةݥੑ͕൐͏ 144

Slide 145

Slide 145 text

1ZUIPOͰμοΫλΠϐϯά #JSE͸#BSL Λ͍࣋ͬͯͳ͍ͷͰ BOJNBMͰ͸ͳ͍൑ఆʹͳΔɻ ͦΕҎ֎͸ಈ෺ͱΈͳ͞ΕΔɻ ๸͑Δݘ ๸͑ͳ͍ௗ ๸͑Δ ϩϘοτ 145

Slide 146

Slide 146 text

2VJ[ (P͸μοΫλΠϐϯάʁ ࣮ࡍʹ࣮૷͔ͯ֬͠Ί͍ͯͩ͘͞ɻ 146

Slide 147

Slide 147 text

(PͰμοΫλΠϐϯά Pythonͱಉ͡Α͏ʹৼΔ෣͍Λຬͨ͞ͳ͍bird͚͕ͩΤϥʔʹͳ Δɻ͜Ε͕Go͕Statick Duck Typingͱݺ͹ΕΔॴҎͰ͋Δɻ https://go.dev/play/p/5TD7PqRseEN 147