Goでのチーム開発に途中参画した私が納得して実装を進めるためにやったこと ~ 命名編 ~
by
m_t_tion1
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
GoͰͷνʔϜ։ൃʹ్தࢀըͨ͠ࢲ͕ ೲಘ࣮ͯ͠ΛਐΊΔͨΊʹͬͨ͜ͱ ~ ໋໊ฤ ~ 2024/06/07@(Unofficial) Go Conference 2024 Pre Party
Slide 2
Slide 2 text
ࣗݾհ 2 Kaoru Muta ໂా ܆ (ϝϯτε) ੜ·ΕҭͪେࡕͰࠓେࡕʹ͍·͢ 20242݄ʹגࣜձࣾBuySell Technologies join. ങऔج൫/๚ങऔʹಛԽͨ͠αʔϏεͷ৽ن։ൃʹैࣄ ങऔɾࠪఆ ങऔछผʹԠͨ͡࠷దͳγεςϜߏங Visit -๚ങऔ- Store -ళฮങऔ- ങऔ ϦϢʔεϓϥοτϑΥʔϜCosmos ࣗࣾ։ൃͷϦϢʔεಛԽۀجװγεςϜͰ͋ΓαʔϏε܈ͷू߹ମ @m_t_tion1
Slide 3
Slide 3 text
ຊൃදͷཁͱϞνϕʔγϣϯ 3 ʮڷ (=Go)ʹೖΒڷʹै͑ʯΛνʔϜͰୡ͢ΔͨΊʹ ίʔσΟϯάʹؔ͢Δҙࢥ౷ҰΛνʔϜͰߦͬͨΒɺ ίʔυʹҰ؏ੑ͕ग़ͨ & ϨϏϡʔίετͱΈϙΠϯτ͕গͳ͘ ͳͬͨ ཁ Ϟνϕ ҎԼͷΛօʹฉ͍ͯΧδϡΞϧʹσΟεΧογϣϯ͍ͨ͠ ● ൃදͰऔΓ্͛Δࣄʹࣅͨૺ۰ͨ͜͠ͱ͕͋Δ͔ ○ ૺ۰ͨ͠߹ɺͲ͏ରॲ͔ͨ͠ ○ ͠ͳ͔ͬͨ߹ɺެࣜͷϧʔϧʹै͏ͷΈͰ ेͩͬͨͷ͔
Slide 4
Slide 4 text
ΦϯϘʔσΟϯά࣌ͷܦݧ 4 ● ࠓ·ͰJavaϝΠϯͰॻ͍͍ͯͨΤϯδχΞ ● GoͰ࡞͍ͬͯΔ0 → 1ͷ৽ن։ൃͷ్தͰJOIN ● طଘίʔυΛ֬ೝ͠ΩϟονΞοϓ ঢ়گ ײ ● Goදݱੑ͕͘ɺॻ͖ํͷΒ͖ͭগͳ͍ͣ (গͳ͘ͱJavaΑΓ) ͔͠͠ɺҎԼͷͰΒ͖͕ͭɾɾ ○ ม໊ͷলུͷํ ○ ϙΠϯλͷ͍ॴ...etc ίʔυϨϏϡʔͷίετ૿Ճ, ॻ͖ํʹ໎͍͕ੜ͡ΔՄೳੑ
Slide 5
Slide 5 text
ΦϯϘʔσΟϯά࣌ͷܦݧ 5 ● ࠓ·ͰJavaϝΠϯͰॻ͍͍ͯͨΤϯδχΞ ● GoͰ࡞͍ͬͯΔ0 → 1ͷ৽ن։ൃͷ్தͰJOIN ● طଘίʔυΛ֬ೝ͠ΩϟονΞοϓ ঢ়گ ײ ● Goදݱੑ͕͘ɺॻ͖ํͷΒ͖ͭগͳ͍ͣ (গͳ͘ͱJavaΑΓ) ͔͠͠ɺҎԼͷͰΒ͖͕ͭɾɾ ○ ม໊ͷলུͷํ ○ ϙΠϯλͷ͍ॴ...etc ίʔυϨϏϡʔͷίετ૿Ճ, ॻ͖ํʹ໎͍͕ੜ͡ΔՄೳੑ ຊൃදͷτϐοΫ
Slide 6
Slide 6 text
6 Έͳ͞Μಉ͡Α͏ͳײΛ ࣋ͬͨ͜ͱ͋Γ·͔͢ʁ
Slide 7
Slide 7 text
7 ࣌ͷࢲͷ߹
Slide 8
Slide 8 text
8 GoͷࢥΛΔͨΊʹ Ұ୴ެࣜdocͱؔ࿈ࢿྉΛړΖ͏
Slide 9
Slide 9 text
9 Effective GoͱGo styleguideͰͷߟ͑ํ ~ʮաෆͳ͍ʯ໋໊ʹ͍ͭͯ ~
Slide 10
Slide 10 text
Effective Go - #names ● ͳ໋໊ආ͚Δ͖ 10 ref: https://go.dev/doc/effective_go#names Good :+1: Bad :-1:
Slide 11
Slide 11 text
Go styleguide - #variable-names ● ʮաෆͳ͍ʯ (= Clarity / Concision) ໋໊Λ͖͢ ○ ม͕ࢀর͞ΕΔൣғ (= Scope)ʹԠͯ͡ҟͳΔ ○ লུ͍ͯ͠είʔϓͰมͷׂ͕ࣗ໌ͳΒOK ○ লུͨ͠มΛ͍είʔϓͰ͍ճ͢ͱՄಡੑ͕མͪΔͨΊNG 11 *ߦݫ֨ͳͷͰͳ͘ɺGo styleguideهࡌͷࢀߟͰհ͞Ε͍ͯΔࣈ ref: https://google.github.io/styleguide/go/decisions#variable-names ͍είʔϓͷྫ (*1~7ߦ) ͍είʔϓͷྫ (*25ߦ~)
Slide 12
Slide 12 text
ݸਓͷݟղ ● େલఏͱͯ͠GoެࣜͰఏএ͍ͯ͠Δࢥʹै͏ ● ݸਓ͓ΑͼνʔϜͰʮաෆͳ໋໊͍ʯͱΛࡲΓ߹Θͤͨํ͕ ࣮ऀɾϨϏϡϫʔͱʹͤʹͳΕΔͷͰʁ ○ ͍είʔϓ ■ Ұ࣌తͳม ■ ؔͷ໊લฦΓ͔ΒΒ͏͕ࣗ໌ͳ߹ ○ ͍είʔϓ ■ ೝෛՙ্͕͕Γͦ͏ͳ߹লུ͠ͳ͍ ■ (ͦͦ͗͢Δείʔϓϝιουͱͯ͠ͷׂΛ ݕ౼͢Δ߹͋Δ) 12
Slide 13
Slide 13 text
13 νʔϜͰࡲΓ߹ΘͤΔ
Slide 14
Slide 14 text
νʔϜͰͷ߹ҙܗ ● ฐνʔϜͰͷʮաෆͳ͍ʯͬͯʁ ○ جຊলུ͠ͳ͍ํͰɺܕείʔϓ͔Βࣗ໌ͩͱஅͨ͠Βলུ͢Δ ○ Defined Type͏߹มͷׂ͕ࣗ໌Ͱ͋ΔͨΊলུͯ͠Α͍ (ল໊ུͨ͠લҰ؏ͯ͠͏͜ͱ) ■ ex. salesContractID → scID bailmentReceiptID → brID ○ ҆ͱͯ͠লུ࠷େ2୯ޠ·Ͱ ex. salesContractDocumentDetail → scdd ͱ͔ආ͚͍ͨ 14
Slide 15
Slide 15 text
ӡ༻ޙͷνʔϜ֎͔ΒͷϑΟʔυόοΫ 15 ● νʔϜͰվΊͯGoͷࢥΛ৮ΕֶͯͿ͜ͱ͕Ͱ͖ͨ ● ίʔυʹҰ؏ੑ͕ग़࣮ͯΛ͢Δ্Ͱ໎͍͕ͳ͘ͳͬͨ ● (͜͜ݸਓͷײͰ͕͢) ίʔυϨϏϡʔͰGoͷࢥʹؔ࿈ ͢Δ໋໊ʹؔͯ͠ࢦఠ͢Δ͜ͱݮͬͨ Good More ● ৽نࢀೖऀ͕͖ͨ࣌ʹಉ༷ͷ͕ٞੜ·ΕΔՄೳੑ͕͋Δ ͦͷͨΊఆظతʹݟ͢͜ͱ͕ඞཁ͔ ○ ຖม͑Δͷӡ༻ίετ͕ߴͦ͏ ○ Goͷࢥʹै͏ͷม͑ͳ͍͍ͯ͘ ○ ʮաෆͳ͍ʯΛೝෛՙɾՄಡੑͷ؍Ͱ ఆظతʹ͢ͷΑͦ͞͏
Slide 16
Slide 16 text
ຊൃදͷཁͱϞνϕʔγϣϯ 16 ʮڷ (=Go)ʹೖΒڷʹै͑ʯΛνʔϜͰୡ͢ΔͨΊʹ ίʔσΟϯάʹؔ͢Δҙࢥ౷ҰΛνʔϜͰߦͬͨΒɺ ίʔυʹҰ؏ੑ͕ग़ͨ & ϨϏϡʔίετͱΈϙΠϯτ͕গͳ͘ ͳͬͨ ཁ Ϟνϕ ҎԼͷΛօʹฉ͍ͯΧδϡΞϧʹσΟεΧογϣϯ͍ͨ͠ ● ൃදͰऔΓ্͛Δࣄʹࣅͨૺ۰ͨ͜͠ͱ͕͋Δ͔ ○ ૺ۰ͨ͠߹ɺͲ͏ରॲ͔ͨ͠ ○ ͠ͳ͔ͬͨ߹ɺެࣜͷϧʔϧʹै͏ͷΈͰ ेͩͬͨͷ͔
Slide 17
Slide 17 text
17 Έͳ͞ΜͲ͏ͯ͠·͔͢ʁ
Slide 18
Slide 18 text
Thank You!