Good interface: Command pattern as an example
by
Masafumi Okura
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
ྑ͍ΠϯλʔϑΣΠεͷ୳ٻ ίϚϯυύλʔϯΛྫʹ େխ࢙ʢ@okuramasafumiʣ ໊ݹRubyձٞ04―େਢԋܳ 2019-06-08ʢʣ
Slide 2
Slide 2 text
ࠓͷൃද͕͋ͪͪ͜ʹ ભҠ͍͖ͯ͠·͢ɻ མޠͩͱࢥָͬͯ͠Έͳ͕Β ͓͔͚͖͍ͬͯͯͩ͘͞!
Slide 3
Slide 3 text
pp self • ໊લɿ͢ͱ·͞;Έʢେխ࢙ʣ • ॴଐɿϑϦʔϥϯε • ׆ಈॴɿ౦ژ • ͖ͳgemɿPry, RSpec • ӡӦͯ͠ΔίϛϡχςΟɿGrow.rb
Slide 4
Slide 4 text
໊ݹRubyձٞ
Slide 5
Slide 5 text
໊ݹRubyձٞ
Slide 6
Slide 6 text
զʑͳͥRubyΛ͏ͷ͔
Slide 7
Slide 7 text
Rubyͷ
Slide 8
Slide 8 text
զʑͳͥRubyΛ͏ͷ͔ • ॻ͖͍͢ • ʮॻ͖͢͞ʯͬͯͳΜͩΖ͏ • ಡΈ͍͢ • ʮಡΈ͢͞ʯͬͯ(ry • Rails
Slide 9
Slide 9 text
զʑ͕RubyΛ͏ཧ༝
Slide 10
Slide 10 text
ϓϩάϥϛϯάָ͕͍͠
Slide 11
Slide 11 text
ͳͥRubyͰϓϩάϥϛϯάΛ͢Δͱ ָ͍͠ͷͩΖ͏͔ʁ
Slide 12
Slide 12 text
https://www.atmarkit.co.jp/news/ 200907/24/ruby2.html
Slide 13
Slide 13 text
yuguiɿ ͦΕɺίϨΫγϣϯ͕͋ͬͯγϟοϑϧ ͍ͨ͠ͱࢥͬͨΒɺshuffleͱॻ͍ͯɺͦΕ Ͱಈ͔ͳ͖Ό͍͚ͳ͍ΜͰ͢Αɻ
Slide 14
Slide 14 text
ࢥͬͨͱ͓Γʹಈ͘ ʢৗʹಈ͘ͱݴ͍ͬͯͳ͍ʣ
Slide 15
Slide 15 text
ͱ͜ΖͰɿ ͳΜͰ͜ͷΛ͍ͯ͠Δͷ͔
Slide 16
Slide 16 text
ָ͘͠ϓϩάϥϛϯάͰ͖Δ ྖҬΛ͍͛ͨʂ
Slide 17
Slide 17 text
ϥΠϒϥϦΛॻ͍ͯΈΑ͏ →ॻ͖·ͨ͠
Slide 18
Slide 18 text
https://github.com/okuramasafumi/ neco
Slide 19
Slide 19 text
150ߦͪΐ͍ͷϥΠϒϥϦ
Slide 20
Slide 20 text
2ճ΄Ͳॻ͖͍ͯ͠Δ
Slide 21
Slide 21 text
ΠϯλʔϑΣΠεʹೲಘ͕͍͔ͳ͔ͬͨ
Slide 22
Slide 22 text
ΠϯλʔϑΣΠεʹ͍ͭͯ ͍Ζ͍Ζߟ͑ͨͷͰɺ ͦͷՌʢʁʣΛڞ༗͍ͨ͠
Slide 23
Slide 23 text
ͦͦɿ ΠϯλʔϑΣΠεͬͯ ͳΜ͚ͩͬʁ
Slide 24
Slide 24 text
Interface (MacOSͷࣙॻΑΓ) 1. a point where two systems, subjects, organizations, etc. meet and interact 2. Computing a device or program enabling a user to communicate with a computer
Slide 25
Slide 25 text
ΠϯλʔϑΣΠε ίϯϐϡʔλͱͷίϛϡχέʔγϣϯ ͷͱΓํΛܾఆ͢Δͷ
Slide 26
Slide 26 text
ΠϯλʔϑΣΠεʹϝιου
Slide 27
Slide 27 text
ΠϯλʔϑΣΠεʹϝιουγάχνϟ
Slide 28
Slide 28 text
ʮࢥͬͨͱ͓Γʹಈ͘ʯ
Slide 29
Slide 29 text
Ruby ΠϯλʔϑΣΠεʢ㲓ϝιουγάχνϟʣ ͕ྑ͍͔ΒΘΕ͍ͯΔ
Slide 30
Slide 30 text
DSL
Slide 31
Slide 31 text
ҎԼɺ ʮDSLʯʮݴޠDSLʯΛࢦ͠·͢
Slide 32
Slide 32 text
Domain Specific Language
Slide 33
Slide 33 text
Ruby͕ΘΕΔཧ༝ͷҰͭ
Slide 34
Slide 34 text
RubyʹΑΔDSLͷ۩ମྫ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ • HomebrewʢύοέʔδϚωʔδϟʣ
Slide 35
Slide 35 text
ڞ௨
Slide 36
Slide 36 text
DSLԿ͔Λఆ͍ٛͯ͠Δ
Slide 37
Slide 37 text
RubyʹΑΔDSLͷ۩ମྫʢ࠶ܝʣ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ • HomebrewʢύοέʔδϚωʔδϟʣ
Slide 38
Slide 38 text
RubyʹΑΔDSLͷ۩ମྫʢఆٛྫ͖ʣ • ActiveRecordʢσʔλϞσϧͷఆٛʣ • RakeʢϏϧυϓϩηεͷఆٛʣ • RSpecʢ·ΕΔৼΔ͍ͷఆٛʣ • PuppetChefɺVagrantʢ֤छΠϯϑϥϦιʔεͷఆٛʣ • Homebrewʢύοέʔδͷఆٛʣ
Slide 39
Slide 39 text
ͱ͜ΖͰɿ DSL୯ͳΔΫϥεϝιου ʢͷ߹͕ଟ͍ʣ
Slide 40
Slide 40 text
ͭ·Γɿ DSL·ͨΠϯλʔϑΣΠε
Slide 41
Slide 41 text
͜͜·Ͱͷ·ͱΊ • ΠϯλʔϑΣΠε͕ྑ͍ͱָ͘͠ϓϩάϥϛϯάͰ͖Δ • ΠϯλʔϑΣΠεͱ͍͍ͩͨϝιουγάχνϟͷ͜ͱ • ֤ॴͰΘΕ͍ͯΔDSL࣮ͨͩͷϝιου • DSLʮఆٛʯʹڧ͍ • ΠϯλʔϑΣΠεʮ७ਮͳϝιουʯͱDSLʹ͚ΒΕΔ
Slide 42
Slide 42 text
https://rubykaigi.org/2019/ presentations/tanaka_akr.html
Slide 43
Slide 43 text
ྑ͍ΠϯλʔϑΣΠεͬͯ ͳΜͩΖ͏ʁʁʁ
Slide 44
Slide 44 text
⚠ ͜Εͯ͢ࢲͷ୯ͳΔҰҙݟͰ͢ Ͳ͔ͬͪͱ͍͏ͱ͕΄͍͠… ࠙ձͰ͓͠·͠ΐ͏
Slide 45
Slide 45 text
ྑ͍ΠϯλʔϑΣΠεͷ̏ݪଇ • ໎Θͳ͍ • ґଘ͠ͳ͍ • ͤ͗͢ͳ͍
Slide 46
Slide 46 text
໎Θͳ͍ • ϝιου໊ʹࡾ୯ݱͷʮsʯඞཁ͚ͩͬʁ • ͋ͷΫϥεcallͰݺͿΜ͚ͩͬɺperform͚ͩͬʁ • Πϯελϯεϝιου͚ͩͬɺΫϥεϝιου͚ͩͬʁ • Ҿͷॱংʁ
Slide 47
Slide 47 text
ґଘ͠ͳ͍ • ϝιουνΣʔϯΛલఏͱ͠ͳ͍ʢಛఆͷฦΓʹґଘ͠ͳ ͍ʣ • ςετ࣌ͷελϒ͕ߴʑҰͭͰࡁΉ
Slide 48
Slide 48 text
ͤ͗͢ͳ͍ • ΤϯυϢʔβʔ͕ࣗྗͰͰ͖Δ͜ͱΒͳ͍ • ୯७ͳόϦσʔγϣϯʹෳࡶͳDSLຊʹඞཁ͔ʁ • ΤϯυϢʔβʔ͕ࣗྗͰΓͮΒ͍͜ͱΛΔ • νΣʔϯͨ͠ϩʔϧόοΫॲཧࣗྗͰ͍͠ʢޙड़ʣ
Slide 49
Slide 49 text
௨ৗͷϝιου͔DSL͔ɺ ͦΕ͕ͩ
Slide 50
Slide 50 text
શ෦ϝιουͰ͍͍͡ΌΜɺ DSLͱ͔֮͑Δͷେมͩ͠ʂ Pure Ruby࠷ߴʂ
Slide 51
Slide 51 text
ͱࢥͬͯͨ࣌ظ͕ʹ͋Γ·ͨ͠…
Slide 52
Slide 52 text
ϝιουΠϯλʔϑΣΠεͷॴ • ҾselfͳͲ͕ࣗ໌ • ܧঝͨ͠ͱ͖ʹಈ࡞͕ཧղ͍͢͠ • ͦ͜ʹʮࠇຐज़ʯͳ͍
Slide 53
Slide 53 text
ϝιουΠϯλʔϑΣΠεͷॴ • ॊೈͳڍಈΛఏڙ͢ΔࡍʹϢʔβʔ͕ॻ͖͘ϝιου͕ࡶ ʹͳΓ͕ͪ • ϥΠϒϥϦ͕ϑϩʔΛίϯτϩʔϧ͠Α͏ͱ͢Δࡍʹඞཁͳ ϑοΫΛࠩ͠ڬΉͷ͕͍͠ʢϢʔβʔʹଟͷϝιουΛఆ ٛͯ͠Β͏ඞཁ͕ग़ͯ͘Δʣ
Slide 54
Slide 54 text
DSLͷॴ • ϒϩοΫҾϝιουҾΑΓॊೈ • దʹ໋໊͞Ε͍ͯΔ߹ɺՄಡੑ͕ߴ͍ • ϥΠϒϥϦ͕ҙͷॲཧΛϢʔβʔఆٛͷॲཧʹڬΈࠐΊΔ ʢϑοΫΩϟογϡͳͲʣ • ԿΛ͍ͨ͠ͷ͔ͷʮఆٛʯΛએݴతʹॻ͚Δ
Slide 55
Slide 55 text
DSLͷॴ • ʮࠇຐज़ʯ͕ଟ͘ͳΓ͕ͪͷͰɺڍಈΛਖ਼֬ʹѲ͢Δͷ͕ࠔ • దʹ໋໊͞Ε͍ͯͳ͍߹ɺՄಡੑ͕ஶ͘͠མͪΔέʔε͕ ͋Δ • ϝλϓϩάϥϛϯάΛར༻͢Δ߹ɺσόοά͕ࠔʹͳΔ
Slide 56
Slide 56 text
ॊೈੑͷͰDSL͕༏Ґ
Slide 57
Slide 57 text
͡Ό͋શ෦DSLΛ༻ҙ͠·͘Ε ͦΕͰ͍͍ͷ͔ʂʁ
Slide 58
Slide 58 text
ࠇຐज़͡Όͳ͍ͷͦΕʁ
Slide 59
Slide 59 text
DSLຐज़͕͍ ʢby Joker1007ʣ
Slide 60
Slide 60 text
அ͕͍͠έʔε
Slide 61
Slide 61 text
ྫɿ όϦσʔγϣϯఆٛͳͷͰDSLΛ͏ ͔͠͠ɺܕνΣοΫΛDSLͰߦ͏͖͔ʁ
Slide 62
Slide 62 text
ճྫɿ ͤ͗͢ͳ͍ݪଇʹै͍ɺ࣮ࡍͷ όϦσʔγϣϯϢʔβʔʹͤΔɺ ϥΠϒϥϦόϦσʔγϣϯఆٛͷ ϑοΫDSLͷΈఏڙ
Slide 63
Slide 63 text
۩ମྫ ʢࠓճͷυϝΠϯίϚϯυύλʔϯʣ
Slide 64
Slide 64 text
NecoϏδωεϩδοΫΛ ʮίϚϯυʯʹׂ͠ɺ ͦΕΒΛΈ߹ΘͤΔϑϩʔΛ ࢧԉ͢ΔϥΠϒϥϦ
Slide 65
Slide 65 text
·ͱΊ • ͔ͤͬ͘RubyͰॻ͍ͯΔΜ͔ͩΒΠϯλʔϑΣΠεʹͩ͜Θ Γ͍ͨʢָ͍ͬͯ͠ϥΠϒϥϦ͕΄͍͠ʣ • DSLRubyͷڧΈͰ͋Γɺదʹ໋໊ɾ࣮͢Ε୯७ͳϝ ιουΑΓॊೈͳఆٛΠϯλʔϑΣΠεΛఏڙͰ͖Δ • ͕Μͬͯॊೈͳ͍উखΛࢦͯ͠ΔͷͰNecoͬͯ͘ΕΑͳʢએʣ