Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
202111Gocon_kaminashi_kimura
Search
kimura
November 30, 2021
1
2.1k
202111Gocon_kaminashi_kimura
kimura
November 30, 2021
Tweet
Share
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Documentation Writing (for coders)
carmenintech
67
4.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
A better future with KSS
kneath
238
17k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Transcript
ϊϯσεΫϫʔΧʔ͚ ϊʔίʔυαʔϏεͷͭΒΈɾ͏·Έ גࣜձࣾΧϛφγ ΞϓϦέʔγϣϯΤϯδχΞ ɹɹɹ ɹɹɹɹଜ Ұ
1. ΧϛφγͷαʔϏεհ a. ݱͷݱঢ় b. ݱΛม͑ΔͨΊͷΧϛφγͷΞϓϩʔν 2. ͏·Έ a. ΧϛφγGoྺ
b. ײͨ͡͏·Έ&֤ΤϯδχΞGoྺ 3. ։ൃʹͨͬͯͷͭΒΈ ຊͷΞδΣϯμ
1. ΧϛφγͷαʔϏεհ
ઃඋɾਗ਼ ཱྀ٬ɾӡ༌ ݐઃ ࢱࢪઃ ۀ εʔύʔɾখച ٬ۀ ҿ৯ళ ݱͰಇ͘3,100ສਓ͕ɺࢴத৺ͰඇޮͳΦϖϨʔγϣϯʹʑΘΕ͍ͯ·͢ɻ ϓϥΠϕʔτͰεϚʔτϑΥϯΛ͍ͬͯΔͷʹɺ৬Ͱͳ͔ͥࢴͱϖϯɺσδΧϝΛ͏ඞཁ͕͋Δͷ͕ݱঢ়Ͱ͢ɻ
ຊͷबۀਓޱͷ͕PCIT͕͑ͳ͍ڥͰಇ͍͍ͯ·͢ Χϛφγ͕ղܾ͍ͨ͜͠ͱ ຊʹ͓͚Δ࿑ಇਓޱͷׂ߹ 9 σεΫ ϫʔΧʔ ϊϯσεΫ ϫʔΧʔ ˋ ˋ 52 48 ※ ಠཱߦ๏ਓ࿑ಇࡦݚڀɾݚमػߏʮ৬ۀผबۀऀʯΑΓࣾࢉग़
ه ֬ೝ ूܭɾՄࢹԽ ޱ಄Ͱࢦಋ ͯ͢ਓྗʹΑΔۀΦϖϨʔγϣϯ
݁Ռͱͯ͠ϛε͕ଟൃ
̋×νΣοΫද ࢴͷνΣοΫϦετʢϫʔΫϑϩʔʣ ΧϛφγͰσδλϧԽ ϊʔίʔυͰݱཧΞϓϦΛ࡞Δ͜ͱ͕Ͱ͖Δ ɹۀϑϩʔΛσδλϧԽ͢Δ
݅ذ ܁Γฦ͠ LOOP IF-ELSE ଟ༷ͳσʔλܕ TYPE ɹϊʔίʔυ͚ͩͲɺᙱ͍ॴʹख͕ಧ͘
LOOP IF-ELSE TYPE ܁Γฦ̍͠ ܁Γฦ̎͠ ܁Γฦ̏͠ ϊʔυ ճ YESͷ߹ Noͷ߹
ߏͰදݱ ɹ෦ͷσʔλߏͰఆ͍ٛͯ͠Δ
2. ΧϛφγͷGoྺͱ͏·Έ
- 2017ͷϓϩμΫτ։ൃ։͔࢝Β4 - Goαʔόબఆཧ༝ - ඪ४tool܈ͷ๛͞ - ॏͳΔมߋʹڧ͍ - ܧঝ͕ଘࡏ͠ͳ͍
- Composition over inheritance (ܧঝΑΓ߹) - Πϯϑϥͷॊೈੑ - ΫϩείϯύΠϧ - ίϯςφԽͱͷ૬ੑ - ࣌Go࠾༻ࣄྫ͕গͳ͍ ɹΧϛφγͷGoྺͱ͏·Έ1
- ੩తܕ͚͕Ͱ͖Δ - 200ͷଟ֊ͷςʔϒϧ - IDEͷࣗಈิ ɹΧϛφγͷGoྺͱ͏·Έ1 table ᶃ֊ߏʢࢠؔʣΛදݱ͢ΔͨΊͷςʔϒϧ ᶄσʔλͷܕ͝ͱʹςʔϒϧ
ɹʢྫ͑ɺܕͱܕςʔϒϧఆ͕ٛҟͳΔʣ ɹɹetc...
ɹ։ൃʹ͓͚Δ͏·Έ2 (੩తܕ͚ݴޠͷதͰ) ະܦݧͷΤϯδχΞ͕शಘ͍͢͠ - ৽نೖࣾऀ্ཱ͕͙͕ͪ͢Δ - ࣾͰͷGoܦݧऀׂ߹= 3/7 Go JavaScr
ipt TypeScr ipt Python Elixir Ruby Java PHP C# C C++ VB Engineer A ◦ ◦ ◦ ◦ B ◦ ◦ ◦ C ◦ ◦ ◦ D ◦ ◦ ◦ E ◦ ◦ ◦ ◦ ◦ ◦ F ◦ ◦ ◦ G ◦ ◦ ◦ ◦ ◦ ฐࣾͷೖࣾલͷΤϯδχΞ༻ݴޠ
3.։ൃʹͨͬͯͷͭΒΈ
ɹͭΒΈ1 ίʔυߦͷ૿Ճ - ϦϨʔγϣϯͷଟ͞ - Preload Λଟ༻
ɹͭΒΈ1 ίʔυߦͷ૿Ճ - ϦϨʔγϣϯͷଟ͞ - genericsͷ༗ແ -> switchจʹཔΒ͟ΔΛಘͳ͍ - ߏͷσʔλ->
forloopͷଟ༻ - ؔ࿈ςʔϒϧͷ૿Ճ - ࢠnodesͷϦϨʔγϣϯ
ɹͭΒΈ2 RDBͰͷੑೳԼ - ؔ࿈ςʔϒϧͷ૿ՃʹΑΓɺapplication ⁶ RDBؒͷ௨৴ճͷ૿Ճ - application ⁶ RDBؒͷ௨৴͕ϘϧτωοΫʹ
gtx. Preload("Rel-A"). Preload("Rel-B"). Preload("Rel-C"). Find(s.ctx, &mainTable).Error; ORMΛͬͨίʔυ select ~~~ select ~~~ select ~~~ ࣮ΫΤϦ - ORMଆͰͷେྔͷΫΤϦൃߦ - ࠶ىॲཧͰͷDBΞΫηεॲཧΛॻ ͍ͯ͠·͍ɺେྔͷΫΤϦൃߦ
ɹͭΒΈ2 RDBͰͷੑೳԼͷରԠ Application ଆ - ΫΤϦൃߦॲཧͱ࠶ىॲཧΛ - ORM༻ -> (ςʔϒϧ݁߹Λߦ͏Α͏ͳ)
ੜΫΤϦʹมߋ → DB ΫΤϦൃߦճΛ͑Δ͜ͱ͕Ͱ͖ͨ DB ଆ - ςʔϒϧ݁߹Ͱ༻͞ΕΔ֎෦Ωʔʹର͢ΔindexͷՃ → ΫΤϦ୯ମͷੑೳͷվળ
ɹͭΒΈ3 ςετσʔλͷ༻ҙ ଟ֊ͷςʔϒϧɾϦϨʔγϣϯঢ়گԼͰͷςετσʔλ४උ - ॳJsonͰ۪ʹॻ͍ͯ͠·͕ͬͨͨΊʹɺAddReport ςετͷ1 test data ͚ͩͰ3000ߦ΄Ͳʹ
None
ɹͭΒΈ3 ςετσʔλͷ༻ҙ ଟ֊ͷςʔϒϧɾϦϨʔγϣϯঢ়گԼͰͷςετσʔλ४උ - ॳJsonͰ۪ʹॻ͍ͯ͠·͕ͬͨͨΊʹɺAddReport ςετͷ1 test data ͚ͩͰ3000ߦ΄Ͳʹ
ɹͭΒΈ3 ςετσʔλ४උͷରԠ Json -> ֎෦module (factory-go) ʹͯɺ֤ objectΛੜ͢ΔΑ͏ʹͨ͠
ɾϊʔίʔυͰ࡞Ͱ͖ΔݱཧΞϓϦʹΑΓɺݱͷDXΛՃͤ͞Α͏ ͱ͍ͯ͠Δ ɾ੩తܕ͚ͷಛੑɺෑډͷ͞ͷͰGoͷԸܙΛड͚͍ͯΔ ɾҰํͰɺଟ֊ͳσʔλߏΏ͑ͷίʔυ૿Ճɺࠓޙ૿͍͑ͯ͘Ͱ͋Ζ ͏RDBͷΞΫηεɺςετσʔλͷରԠ͕՝ײͱͯ͋͠Δ ɹ·ͱΊ
None
ΦϑΟεʹͬͯ͜ɺ૾͚ͩͰҙࢥܾఆ͢Δɻ టष͍͜ͱ͔ΒڑΛஔ͖ɺखΛൈ͘ɻ ސ٬ͱ͞ͳ͍ɻݱͷΛฉ͜͏ͱ͠ͳ͍ɻ ϢʔβʔࢹͰͳ͘ɺࣗࣾ߹Λ༏ઌ͢Δɻ Don'ts ݱʹϖΠϯΛମײ͠ʹߦ͘ϝϯόʔ ϢʔβʔͷΛฉͨ͘Ίɺ෦ॺΘͣݱ ݱυϦϒϯͳΤϐιʔυ
None
ఆྫϛʔςΟϯάɾࣄۀઓུϛʔςΟϯά શࣾɾνʔϜͰͷΦϑαΠτϛʔςΟϯά ใͷಁ໌ੑɺຊԻΛͿ͚ͭ߹͏Φʔϓϯίϛϡχέʔγϣϯ શ։ΦʔϓϯͳΤϐιʔυ ࣗͷྑ͍ͱ͜Ζɺද໘తͳ͔͠ڞ༗͠ͳ͍ɻ ϓϥΠυ͕ߴ͘ɺΞυόΠεΛ߈ܸͩͱड͚औΔɻ ٞʹͳΔͱػݏ͕ѱ͘ͳΔɻ ߹ͷ͍͍ӕΛͭ͘ɻ ཧɺͷΈͰҙࢥܾఆ͠ɺҙݟΛฉ͔ͳ͍ɻ ྑ͜͠Α͠ͰɺͿ͔ͭΔ͜ͱΛڪΕΔɻ
ຊਓ͕͍ͳ͍ॴͰݴ͏ɻ Don'ts શࣾһͰࣗࣾͷΧϧνϟʔʹ͍ͭͯҙݟΛग़͠߹͏ ΤϯδχΞνʔϜͷϛʔςΟϯάͷ༷ࢠ ਓੜνϟʔτൃද
None
ා͕ͬͯνϟϨϯδ͠ͳ͍ɻ ࣦഊͯ͠Կֶͳ͍ɻ ࣦഊΛڐ༰͢ΔจԽΛצҧ͍͍ͯ͠Δɻ ͙ͨ͢͜ΕΔɻมʹߟ͑͗͢Δɻ ϓϥΠυ͕ߴ͍ɻ ࢹ࠲ɾࢹ͕͍ɻߴΈΛࢦ͞ͳ͍ɻ Don'ts ΧϛφγͷࣄͷελΠϧɻߟ͑ൈ͍ͨΒɺ·ͣͬͯΈΔɻ β൛ϚΠϯυͳΤϐιʔυ ࠾༻ΟογϡϦετ
νʔϜͷΈͮ͘Γ Έͮ͘Γ੍ γϦʔζAࢿۚௐୡ ։ൃϓϩδΣΫτ 3
EM/ΞϓϦΤϯδχΞ/SRE ੵۃ࠾༻த