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

Joyful user foundation restructuring with Ruby

Joyful user foundation restructuring with Ruby

RubyWorld Conference 2017 での講演資料です。

70e13d9877054026fda46d5a5b53a236?s=128

MOROHASHI Kyosuke

November 01, 2017
Tweet

Transcript

  1. RubyʹΑΔ ͨͷ͍͠Ϣʔβʔج൫࠶ߏங RubyWorld Conference 2017 2017-11-01 ॾڮګհ @moro 

  2. ‣ (ࣸਅ) ղফͰ͖ͨෆ҆ 

  3.  Kyosuke MOROHASHI moro moro

  4. None
  5. None
  6.  http://techlife.cookpad.com/entry/2017/04/06/172601

  7. RubyʹΑΔ ͨͷ͍͠Ϣʔβʔج൫࠶ߏங 

  8. RubyʹΑΔ ͨͷ͍͠Ϣʔβʔج൫࠶ߏங 

  9. ‣ ❌ ͓΋͠Ζ͓͔͍͠ ‣ ⭕ ͍͖͍͖ͱલ޲͖ʹऔΓ૊ΊΔ ʮͨͷ͍͠ʯ 

  10. “ And there's business value in fun - after all

    motivation is a major factor in programmer productivity. 
 ͦΕ͔Βɺʮָ͠͞ʯʹ΋ϏδωεՁ஋͕͋Γ·͢ŠŠ݁ہɺϞνϕʔγϣϯ ͕ͦ͜ϓϩάϥϚͷੜ࢈ੑΛࠨӈ͢ΔͷͰ͢ɻ https://martinfowler.com/bliki/DynamicTyping.html 
 ( http://bliki-ja.github.io/DynamicTyping/ )
  11. “ ΘΕΘΕ͸ػցͰ͸ͳ͍ͷͰɺ΍Γ͍ͨͱࢥ͏ͱ͖ ʹɺԿ͔Λୡ੒Ͱ͖ΔΜͰ͢ɻԿ͔Λୡ੒͢Δʹ͸ɺ ಥ͖ಈ͔͢಺ͳΔྗ͕ඞཁͰ͢ɻͦΕ͸Ϟνϕʔγϣ ϯʹΑͬͯݱΕΔΜͰ͢Ͷɻ ུ ϞνϕʔγϣϯΛ সͬͯ͸͍͚ͳ͍ɻ 「なんでRubyなんか作った!? 迷惑だ!」に対するMatzの答え


    
 http://el.jibun.atmarkit.co.jp/rails/2012/10/ruby-matz-7080.html
  12. “ ͭ·Γʮ͜Μͳ͜ͱΛݴͬͨΒνʔϜϝΠτ͔Βഅࣛʹ͞ Εͳ͍ͩΖ͏͔ʯɺ͋Δ͍͸ʮϦʔμʔ͔ΒࣤΒΕͳ͍ͩ Ζ͏͔ʯͱ͍ͬͨෆ҆ΛɺνʔϜͷϝϯόʔ͔Β෷১͢Δɻ ৺ཧֶͷઐ໳༻ޠͰ͸ʮ৺ཧత҆શੑʢQTZDIPMPHJDBM TBGFUZʣʯͱݺ͹ΕΔ҆Β͔ͳงғؾΛνʔϜ಺ʹҭΊΔ ͔Ͳ͏͔͕ɺ੒ޭͷ伴ͳͷͩͱ͍͏ɻ グーグルが突きとめた!社員の「生産性」を高める唯一の方法はこうだ
 --プロジェクト・アリストテレスの全貌
 


    http://gendai.ismedia.jp/articles/-/48137
  13.  ‣ ਓʑΛ࠷ߴʹً͔ͤΔ ‣ ߴ଎ʹ࣮ݧֶश͢Δ ‣ ܧଓతʹՁ஋Λಧ͚Δ ‣ ҆શΛඞਢ৚݅ʹ͢Δ http://modernagile.org/

  14. RubyʹΑΔ ͨͷ͍͠Ϣʔβʔج൫࠶ߏங 

  15. RubyʹΑΔ ͨͷ͍͠Ϣʔβʔج൫࠶ߏங 

  16. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  17. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  18.  http://techlife.cookpad.com/entry/2017/04/06/172601

  19. ‣ 10೥લ ‣ rails generate scaffold users
 email:string password_digest:string ‣

    ݱࡏ ‣ ͜Ε·Ͱ࢖ͬͯ͘Ε͍ͯΔϢʔβʔ͞Μʹ໎࿭Λ͔͚ͳ͍Α͏ ஫ҙΛ͸Β͍ͭͭɺϏδωεχʔζͰ͏·Εͨଟछଟ༷ͳ֓೦ ΍σʔλߏ଄Λ੔ཧͯ͠ɺࠓޙͷαʔϏεల։ͷج൫ͱͳΔɻ ؆୯ͳ໰୊͸͋·Γ࢒͍ͬͯͳ͍ 
  20. ‣ ݄࣍ར༻ऀ਺ɿ໿6000ສਓ ‣ ϓϨϛΞϜձһ਺ɿ190ສਓҎ্ ‣ ͜ͷํͨͪʹ໎࿭Λ͔͚ͳ͍͜ͱΛେલఏͱ͠ɺ
 ֓೦Λ੔ཧͯ͠ɺ࣮૷΋γϯϓϧʹ͍ͯ͘͠ɻ ؆୯ͳ໰୊͸͋·Γ࢒͍ͬͯͳ͍  ˞਺ࣈ͸೥݄຤࣌఺

  21. The Recipe for the World’s Largest Rails Monolith Akira Matsuda

    https://speakerdeck.com/a_matsuda/the-recipe-for-the-worlds-largest-rails-monolith
  22. ҙࣝͯͨ͠ͷ͍ͨ͘͠͠ 

  23. 

  24. 

  25. “ 3VCZ͸ʮͨͷ͠͞ʯΛୈҰͷ໨ඪʹͨ͠ੈքॳͷϓ ϩάϥϛϯάݴޠͰ͢ɻ — Rubyアプリケーションプログラミング 「1.3 Rubyの哲学」

  26. ‣ ੲ͸৽ਐؾӶͷWebϑϨʔϜϫʔΫͩͬͨɻ ‣ ޿͘࢖ΘΕͨ݁Ռɺ͍·͸Ѫ଀ͱ΋ʹूΊΔɻ Rails 10೥࢙ 

  27.  http://techlife.cookpad.com/entry/2017/04/06/172601

  28. ‣ จࣈ௨ΓͷʮϨΨγʔʯ= Ҩ࢈ ‣ ࢲͨͪͷϏδωε͸ɺ͜ͷίʔυ͕͓ۚΛՔ͍Ͱ͘ Ε͍ͯΔ͔Βͦ͜Ͱ͖͍ͯΔɻ ϨΨγʔίʔυ 

  29. “ Regardless of what we discover, we understand and truly

    believe that everyone did the best job they could, given what they knew at the time, their skills and abilities, the resources available, and the situation at hand. ͜ͷձͰ͸ɺϓϩδΣΫτͷશһ͕ஔ͔Εͨঢ়گԼͰϕετΛਚͨ͘͠ɺͱ͍ ͏͜ͱΛٙͬͯ͸ͳΒͳ͍ ฏು༁  http://www.retrospectives.com/pages/retroPrimeDirective.html
  30. ‣ Ruby Ͱனͷ࢓ࣄ͕Ͱ͖ΔΑ͏ʹͳͬͨɻ ‣ ͦΕࣗମ͕ɺࢲͨͪʹͱͬͯ͸ͱͯ΋ҒେͳҨ࢈ɻ ‣ ͪΌΜͱɺΞοϓσʔτΛ͍ͯ͘͠ɻ Rails 10೥࢙ 

  31. “ b6TFBMMUIFXJTFBOELOPXMFEHFZPVIBWFPG ZPVSPXO 4BN` ʮ͓લ͕ࣗ෼Ͱ͍࣋ͬͯΔஐܙ΍஌ࣝΛ͋ΔݶΓ࢖ͬͯ͝ ΒΜΑɺαϜɺʯ — 指輪物語「王の帰還」

  32. ‣ Fat Controller, Fat Model … ‣ Trailblazer ΍ Hanami

    ͕ྲྀߦ͍ͬͯΔ Is Rails dead? 
  33. ‣ πʔϧ΍ϑϨʔϜϫʔΫΛͨͩద༻͢ Δ͚ͩͰ͸͏·͍͔͘ͳ͍ɻ ‣ എܠʹͳ͍ͬͯͦ͏ͳίϯηϓτΛɺ ࣗ෼ͨͪͰͪΌΜͱࢼͯ͠ΈΑ͏ɻ ͜ͷ10೥ͷֶͼ: 

  34.  αʔϏε૚ͱͯ͠ͷ Form Object ΛΑ͘ߟ͑ͯΈΔ

  35. ‣ ςετՄೳͳʮϞσϧ૚ʯ͸༗༻ɻ ‣ ʮϓϨθϯςʔγϣϯͱυϝΠϯͷ෼཭ʯͬͯ΍ͭ ‣ ίϯτϩʔϥ͔Β͸ৗʹ who ͱ when ͕౉͞ΕΔɻ

    ‣ ActiveSupport::CurrentAttributes ͳΔ΄Ͳɻ ‣ ͩΜͩΜʮϑΥʔϜʯ͡Όͳ͍͜ͱ΋෼͔͖ͬͯͨɻ ‣ αʔϏεΛʮೖΕࢠʯʹ͍ͨ͜͠ͱ΋͋Δɻ αʔϏε૚ͱͯ͠ͷ Form Object 
  36.  Value ObjectΛൃݟ͢Δ

  37. ‣ ొ࿥தͷσʔλ͸ ʮ validate: false ͳϢʔβʔʯͰ͸
 ͳ͍ɻ ‣ ొ࿥ͦΕࣗମ΋ҰͭͷେࣄͳػೳͰ͋Δɻ ‣

    Registration ͱ͍͏֓೦Λൃݟͨ͠ɻ ‣ ಉ࣌ʹɺొ࿥ޙʹͪΌΜͱݩͷίϯςΩετʹ໭͢ͷ΋
 ͱͯ΋େࣄͱ͍͏͜ͱ΋ɺֶΜͩɻ ͜Ε·ͰͷϏδωε͔Β΋ֶͿ 
  38. resources :email_registrations, only: %i(show new create) do collection do get

    :thanks end resource :user, controller: :cookpad_users,
 only: %i(show new create), module: :email_registrations end end ‣ &ϝʔϧͰͷϢʔβʔొ࿥ email_registrations ࣗମΛϦιʔεͱͯ͠ѻ͏ɻ ‣ ͔ͦ͜ΒผϦιʔεͱͯ͠Ϣʔβʔ(cookpad_users)Λ࡞Δɻ 
  39. ίʔυΛॻ͘ͷ͸
 ͨͷ͍͠ 

  40. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  41. “ b6TFBMMUIFXJTFBOELOPXMFEHFZPVIBWFPG ZPVSPXO 4BN` ʮ͓લ͕ࣗ෼Ͱ͍࣋ͬͯΔஐܙ΍஌ࣝΛ͋ΔݶΓ࢖ͬͯ͝ ΒΜΑɺαϜɺʯ — 指輪物語「王の帰還」

  42. ‣ ;Γ͔͑Γ ‣ ݟੵΓͱܭըͮ͘Γ ͍ΖΜͳϓϥΫςΟε͕͋Δ͚Ͳɺͪΐͬͱͣͭࢼͨ͠: 

  43. ‣ ;Γ͔͑Γ ‣ ͜Ε·ͰʹԿΛ͔ͨ͠ ‣ ݟੵΓͱܭըͮ͘Γ ‣ ͜Ε͔ΒԿΛ͢Δ͔ ͍ΖΜͳϓϥΫςΟε͕͋Δ͚Ͳɺͪΐͬͱͣͭࢼͨ͠: 

  44. 

  45.  ‣ ຖि n ϙΠϯτਐΜͰ͍Δͷ͸Θ͔ͬͨɻ͕ɺ ʮ͍ͭͰ͖Δʯ͔͕ݟ͑ͮΒ͔ͬͨɻ ‣ ࣮ࡍʹॻ͍ͯΈͨΒɺײ͕֮දݱͰ͖ͯͨɻ

  46. 

  47.  ‣ ࣾ಺ͷϓϥΫςΟεΛ༌ೖͨ͠ɻ ‣ υϝΠϯΤΩεύʔτʹ͞Θͬͯ΋Β͏ɻ ‣ େখ༷ʑͷؾ͍ͮͨ͜ͱΛͲΜͲΜ௚͢ɻ

  48.  Χϯόϯʹ5SZΛషΔ

  49.  ‣ TryΛ͍ͭ΋໨ʹ͢ΔΑ͏ʹɺషͬͨɻ ‣ ͜Ε͸ະମݧͩͬͨΑ͏ͳɻ

  50.  ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠

  51. ‣ ʮ͜Ε·ͰʯʹֶΜͰ ‣ RailsҰൠ΍ΞϓϦέʔγϣϯίʔυͷۤ࿑ ‣ ػೳͷ࢖ΘΕํ ‣ ʮ͜Ε͔ΒʯΛߟ͑Δ ‣ ͪΐͬͱͣͭʮΑ͍ʯઃܭΛ͢Δ

    ‣ ඞཁͳΒٕज़తෛ࠴ΛआΓೖΕΔ ࣅ͍ͯΔ 
  52. ‣ ʮ͜Ε·ͰʯʹֶΜͰ ‣ ͜Ε·ͰͷΠςϨʔγϣϯͰͷνʔϜͷਐΊํɻ ‣ ࡞Ζ͏ͱͨ͠ػೳͰ΄Μͱ͏ʹඞཁͩͬͨ΋ͷɻ ‣ ʮ͜Ε͔ΒʯΛߟ͑Δ ‣ Try

    ‣ ͜Ε·ͰΛ౿·͑ͨݟੵΓͱܭըͮ͘Γɻ ࣅ͍ͯΔ 
  53. ࣗݾ૬ࣅੑ͕͋Δ 

  54. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  55. ʮ஌͍ͬͯͨʯ͜ͱ 

  56. “ ͕ͩɺߴΈʹ౸ୡ͢Δ͜ͱ͕໨తͰ͋Ε͹ɺιϑτ ΢ΣΞ։ൃ͸ʮϓϩάϥϚʔͱͦͷଞେ੎ʯͰ੒ཱ ͢Δ΋ͷͰ͸ͳ͍ɻͦΕ͕ɺաڈ೥ؒͰࢲֶ͕Μ ͩ͜ͱͩɻ — エクストリーム・プログラミング 「第25章 結論」

  57. “ 5IFSFTBEJ⒎FSFODFCFUXFFO LOPXJOHUIFQBUIBOEXBMLJOHUIFQBUI ಓΛ஌Δ͜ͱͱา͖ͩ͢͜ͱ͸ҧ͏ — Morpheus; Matrix

  58. 

  59. “ 91ͷՁ஋͸ɺϏδωεͷੈքͰ࣮ફ͢΂͖΋ͷͩɻ շదʹ฻ΒͤΔੜ׆ΛૹΔ͚ͩͰͳ͘ɺؔ܎ऀશһ ͕͓ޓ͍ʹϦεϖΫτͨ͠ਓؒؔ܎ʹΑͬͯɺ৽͠ ͍ಇ͖ํΛ։ൃ͢ΔͷͰ͋Δɻ ུ ૑଄తʹ͍͖͍ ͖ͱಇ͘ͷͰ͋Δɻ — エクストリーム・プログラミング

    「第25章 結論」
  60. ‣ ͔ͭͯ͸ਖ਼͔ͬͨ͠લఏ (ϝʔϧΞυϨε͕͋ΔɺͳͲ) ͕ඞཁҎ্ʹ
 ޿ൣʹద༻͞Ε͍ͯΔɻ ‣ ͔ͭͯ͸ʮϝʔϧΞυϨεΛೖྗͯ͠Ϣʔβʔొ࿥ʯΛલఏͱ͍ͯͨ͠ɻ ‣ ϝʔϧΞυϨεೖྗΛল͍ͯɺ༗ྉձһͱͯ͠࢖͍͍ͨͱݴͬͯ͘ΕΔ
 Ϣʔβʔ͞Μ΋ग़͖ͯͨɻ

    ‣ ʮΞϓϦΛΠϯετʔϧͯ͘͠ΕͨʯΒϢʔβʔͱѻ͏࢓૊Έ͕͍ΔͷͰ͸ɻ ࣗ෼ͨͪͷϏδωεͷϢʔβʔঢ়ଶΛֶशͰ͖͖ͯͨ 
  61. ‣ αʔϏε։ൃͷ֤ॴͰѻ͍ͮΒ͘ͳ͍ͬͯΔɻ ‣ ίϛϡχέʔγϣϯܥͷػೳͰܾࡁखஈΛҙࣝ͠ͳ͍ͱ͍͚ͳ͍ɺͳͲɻ ‣ اը΍αϙʔτ΋೉͚͠Ε͹ɺ࣮૷্ͷམͱ݀͠ʹͳΔ͜ͱ΋͋Δɻ ‣ ৽͘͠ೖࣾͨ͠ਓ͕ཧղ͢Δͷ΋೉͍͠ɻ σʔλঢ়ଶ͕೉͍͠ 

  62. “ νʔϜ͕ҙࣝతʹ౒ྗ͢Ε͹ɺυϝΠϯϞσϧ͸ͦ ͷڞ௨ݴޠͷج൫ͱͳΕΔ͠ɺͦͷҰํͰɺνʔϜ ͷίϛϡχέʔγϣϯΛιϑτ΢ΣΞͷ࣮૷ͱ݁ͼ ͚ͭΔ͜ͱ΋Ͱ͖Δɻ ドメイン駆動設計 「第2章 コミュニケーションと言語の使い方」

  63. 

  64. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  65. “ ͦͷϓϩηεͷͳ͔Ͱɺ։ൃऀͱͯ͠࠷ળΛਚ͘͢ ͜ͱͩɻϏδωεͷͨΊʹͳΔ༏ΕͨίʔυΛॻ͘ ͜ͱͩɻ — エクストリーム・プログラミング 「第1章 XPとは何か」

  66. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  67. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠

  68.  http://techlife.cookpad.com/entry/2017/04/06/172601

  69. ‣ ݄࣍ར༻ऀ਺ɿ໿6000ສਓ ‣ ϓϨϛΞϜձһ਺ɿ190ສਓҎ্ ‣ ͜ͷํͨͪʹ໎࿭Λ͔͚ͳ͍͜ͱΛେલఏͱ͠ɺ
 ֓೦Λ੔ཧͯ͠ɺ࣮૷΋γϯϓϧʹ͍ͯ͘͠ɻ ؆୯ͳ໰୊͸͋·Γ࢒͍ͬͯͳ͍  ˞਺ࣈ͸೥݄຤࣌఺

  70. 

  71. ‣ ٕज़తෛ࠴ΛआΓೖΕͳ͕ΒਐΊΔ ‣ Ұ࣌తʹDBͷಉςʔϒϧ΁ෳ਺ΞϓϦέʔγϣϯ͔Β write͢Δͱ͔ ‣ ࠓճ΋ͦͷதͰϕετΛਚ͘͢ ‣ ػೳͷείʔϓΛ෼͚ͯͪΐͬͱͣͭग़͢ɻ ‣

    ม਺ͷείʔϓ΋෼͚ΔɺςετՄೳʹ͢Δ… etc ࣍ͷʮϨΨγʔʯΛ͍ͭͬͯ͘Δͷ͔΋… 
  72. “ 5IFSFTBEJ⒎FSFODFCFUXFFO LOPXJOHUIFQBUIBOEXBMLJOHUIFQBUI ಓΛ஌Δ͜ͱͱา͖ͩ͢͜ͱ͸ҧ͏ — Morpheus; Matrix

  73. ҙࣝͯͨ͠ͷ͍ͨ͘͠͠ 

  74. “ ͦΕ͔Βɺʮָ͠͞ʯʹ΋
 ϏδωεՁ஋͕͋Γ·͢ http://bliki-ja.github.io/DynamicTyping/

  75. 

  76. ίʔυΛॻ͘ͷ͕ͨͷ͍͠ νʔϜͰ։ൃ͢Δͷ͕ͨͷ͍͠ νʔϜͱνʔϜͷ֎ͷਓͱ ΈΜͳͰαʔϏεΛಧ͚Δͷ͕ͨͷ͍͠