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
Good interface: Command pattern as an example
Search
Masafumi Okura
June 08, 2019
Programming
1
980
Good interface: Command pattern as an example
Masafumi Okura
June 08, 2019
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
Why did my proposals get rejected?
okuramasafumi
1
440
A suggestion for the future of RDoc
okuramasafumi
1
66
15 JSON serializers for Ruby
okuramasafumi
2
110
Tech Events, Should We See Them from the Outside or the Inside?
okuramasafumi
1
39
Creating gems 101
okuramasafumi
1
82
How NOT to make your DSL terrible
okuramasafumi
0
280
オブジェクトしこう
okuramasafumi
2
210
Debugging Alba
okuramasafumi
1
190
Learning Ruby
okuramasafumi
5
560
Other Decks in Programming
See All in Programming
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
現場で役立つモデリング 超入門
masuda220
PRO
15
3.2k
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
520
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
110
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
150
Click-free releases & the making of a CLI app
oheyadam
2
110
Ethereum_.pdf
nekomatu
0
460
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Scaling GitHub
holman
458
140k
We Have a Design System, Now What?
morganepeng
50
7.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Embracing the Ebb and Flow
colly
84
4.5k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Building Adaptive Systems
keathley
38
2.3k
Transcript
ྑ͍ΠϯλʔϑΣΠεͷ୳ٻ ίϚϯυύλʔϯΛྫʹ େխ࢙ʢ@okuramasafumiʣ ໊ݹRubyձٞ04―େਢԋܳ 2019-06-08ʢʣ
ࠓͷൃද͕͋ͪͪ͜ʹ ભҠ͍͖ͯ͠·͢ɻ མޠͩͱࢥָͬͯ͠Έͳ͕Β ͓͔͚͖͍ͬͯͯͩ͘͞!
pp self • ໊લɿ͢ͱ·͞;Έʢେխ࢙ʣ • ॴଐɿϑϦʔϥϯε • ׆ಈॴɿ౦ژ • ͖ͳgemɿPry,
RSpec • ӡӦͯ͠ΔίϛϡχςΟɿGrow.rb
໊ݹRubyձٞ
໊ݹRubyձٞ
զʑͳͥRubyΛ͏ͷ͔
Rubyͷ
զʑͳͥRubyΛ͏ͷ͔ • ॻ͖͍͢ • ʮॻ͖͢͞ʯͬͯͳΜͩΖ͏ • ಡΈ͍͢ • ʮಡΈ͢͞ʯͬͯ(ry •
Rails
զʑ͕RubyΛ͏ཧ༝
ϓϩάϥϛϯάָ͕͍͠
ͳͥRubyͰϓϩάϥϛϯάΛ͢Δͱ ָ͍͠ͷͩΖ͏͔ʁ
https://www.atmarkit.co.jp/news/ 200907/24/ruby2.html
yuguiɿ ͦΕɺίϨΫγϣϯ͕͋ͬͯγϟοϑϧ ͍ͨ͠ͱࢥͬͨΒɺshuffleͱॻ͍ͯɺͦΕ Ͱಈ͔ͳ͖Ό͍͚ͳ͍ΜͰ͢Αɻ
ࢥͬͨͱ͓Γʹಈ͘ ʢৗʹಈ͘ͱݴ͍ͬͯͳ͍ʣ
ͱ͜ΖͰɿ ͳΜͰ͜ͷΛ͍ͯ͠Δͷ͔
ָ͘͠ϓϩάϥϛϯάͰ͖Δ ྖҬΛ͍͛ͨʂ
ϥΠϒϥϦΛॻ͍ͯΈΑ͏ →ॻ͖·ͨ͠
https://github.com/okuramasafumi/ neco
150ߦͪΐ͍ͷϥΠϒϥϦ
2ճ΄Ͳॻ͖͍ͯ͠Δ
ΠϯλʔϑΣΠεʹೲಘ͕͍͔ͳ͔ͬͨ
ΠϯλʔϑΣΠεʹ͍ͭͯ ͍Ζ͍Ζߟ͑ͨͷͰɺ ͦͷՌʢʁʣΛڞ༗͍ͨ͠
ͦͦɿ ΠϯλʔϑΣΠεͬͯ ͳΜ͚ͩͬʁ
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
ΠϯλʔϑΣΠε ίϯϐϡʔλͱͷίϛϡχέʔγϣϯ ͷͱΓํΛܾఆ͢Δͷ
ΠϯλʔϑΣΠεʹϝιου
ΠϯλʔϑΣΠεʹϝιουγάχνϟ
ʮࢥͬͨͱ͓Γʹಈ͘ʯ
Ruby ΠϯλʔϑΣΠεʢ㲓ϝιουγάχνϟʣ ͕ྑ͍͔ΒΘΕ͍ͯΔ
DSL
ҎԼɺ ʮDSLʯʮݴޠDSLʯΛࢦ͠·͢
Domain Specific Language
Ruby͕ΘΕΔཧ༝ͷҰͭ
RubyʹΑΔDSLͷ۩ମྫ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ •
HomebrewʢύοέʔδϚωʔδϟʣ
ڞ௨
DSLԿ͔Λఆ͍ٛͯ͠Δ
RubyʹΑΔDSLͷ۩ମྫʢ࠶ܝʣ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • PuppetChefɺVagrantʢDevOpsܥʣ •
HomebrewʢύοέʔδϚωʔδϟʣ
RubyʹΑΔDSLͷ۩ମྫʢఆٛྫ͖ʣ • ActiveRecordʢσʔλϞσϧͷఆٛʣ • RakeʢϏϧυϓϩηεͷఆٛʣ • RSpecʢ·ΕΔৼΔ͍ͷఆٛʣ • PuppetChefɺVagrantʢ֤छΠϯϑϥϦιʔεͷఆٛʣ •
Homebrewʢύοέʔδͷఆٛʣ
ͱ͜ΖͰɿ DSL୯ͳΔΫϥεϝιου ʢͷ߹͕ଟ͍ʣ
ͭ·Γɿ DSL·ͨΠϯλʔϑΣΠε
͜͜·Ͱͷ·ͱΊ • ΠϯλʔϑΣΠε͕ྑ͍ͱָ͘͠ϓϩάϥϛϯάͰ͖Δ • ΠϯλʔϑΣΠεͱ͍͍ͩͨϝιουγάχνϟͷ͜ͱ • ֤ॴͰΘΕ͍ͯΔDSL࣮ͨͩͷϝιου • DSLʮఆٛʯʹڧ͍ •
ΠϯλʔϑΣΠεʮ७ਮͳϝιουʯͱDSLʹ͚ΒΕΔ
https://rubykaigi.org/2019/ presentations/tanaka_akr.html
ྑ͍ΠϯλʔϑΣΠεͬͯ ͳΜͩΖ͏ʁʁʁ
⚠ ͜Εͯ͢ࢲͷ୯ͳΔҰҙݟͰ͢ Ͳ͔ͬͪͱ͍͏ͱ͕΄͍͠… ࠙ձͰ͓͠·͠ΐ͏
ྑ͍ΠϯλʔϑΣΠεͷ̏ݪଇ • ໎Θͳ͍ • ґଘ͠ͳ͍ • ͤ͗͢ͳ͍
໎Θͳ͍ • ϝιου໊ʹࡾ୯ݱͷʮsʯඞཁ͚ͩͬʁ • ͋ͷΫϥεcallͰݺͿΜ͚ͩͬɺperform͚ͩͬʁ • Πϯελϯεϝιου͚ͩͬɺΫϥεϝιου͚ͩͬʁ • Ҿͷॱংʁ
ґଘ͠ͳ͍ • ϝιουνΣʔϯΛલఏͱ͠ͳ͍ʢಛఆͷฦΓʹґଘ͠ͳ ͍ʣ • ςετ࣌ͷελϒ͕ߴʑҰͭͰࡁΉ
ͤ͗͢ͳ͍ • ΤϯυϢʔβʔ͕ࣗྗͰͰ͖Δ͜ͱΒͳ͍ • ୯७ͳόϦσʔγϣϯʹෳࡶͳDSLຊʹඞཁ͔ʁ • ΤϯυϢʔβʔ͕ࣗྗͰΓͮΒ͍͜ͱΛΔ • νΣʔϯͨ͠ϩʔϧόοΫॲཧࣗྗͰ͍͠ʢޙड़ʣ
௨ৗͷϝιου͔DSL͔ɺ ͦΕ͕ͩ
શ෦ϝιουͰ͍͍͡ΌΜɺ DSLͱ͔֮͑Δͷେมͩ͠ʂ Pure Ruby࠷ߴʂ
ͱࢥͬͯͨ࣌ظ͕ʹ͋Γ·ͨ͠…
ϝιουΠϯλʔϑΣΠεͷॴ • ҾselfͳͲ͕ࣗ໌ • ܧঝͨ͠ͱ͖ʹಈ࡞͕ཧղ͍͢͠ • ͦ͜ʹʮࠇຐज़ʯͳ͍
ϝιουΠϯλʔϑΣΠεͷॴ • ॊೈͳڍಈΛఏڙ͢ΔࡍʹϢʔβʔ͕ॻ͖͘ϝιου͕ࡶ ʹͳΓ͕ͪ • ϥΠϒϥϦ͕ϑϩʔΛίϯτϩʔϧ͠Α͏ͱ͢Δࡍʹඞཁͳ ϑοΫΛࠩ͠ڬΉͷ͕͍͠ʢϢʔβʔʹଟͷϝιουΛఆ ٛͯ͠Β͏ඞཁ͕ग़ͯ͘Δʣ
DSLͷॴ • ϒϩοΫҾϝιουҾΑΓॊೈ • దʹ໋໊͞Ε͍ͯΔ߹ɺՄಡੑ͕ߴ͍ • ϥΠϒϥϦ͕ҙͷॲཧΛϢʔβʔఆٛͷॲཧʹڬΈࠐΊΔ ʢϑοΫΩϟογϡͳͲʣ • ԿΛ͍ͨ͠ͷ͔ͷʮఆٛʯΛએݴతʹॻ͚Δ
DSLͷॴ • ʮࠇຐज़ʯ͕ଟ͘ͳΓ͕ͪͷͰɺڍಈΛਖ਼֬ʹѲ͢Δͷ͕ࠔ • దʹ໋໊͞Ε͍ͯͳ͍߹ɺՄಡੑ͕ஶ͘͠མͪΔέʔε͕ ͋Δ • ϝλϓϩάϥϛϯάΛར༻͢Δ߹ɺσόοά͕ࠔʹͳΔ
ॊೈੑͷͰDSL͕༏Ґ
͡Ό͋શ෦DSLΛ༻ҙ͠·͘Ε ͦΕͰ͍͍ͷ͔ʂʁ
ࠇຐज़͡Όͳ͍ͷͦΕʁ
DSLຐज़͕͍ ʢby Joker1007ʣ
அ͕͍͠έʔε
ྫɿ όϦσʔγϣϯఆٛͳͷͰDSLΛ͏ ͔͠͠ɺܕνΣοΫΛDSLͰߦ͏͖͔ʁ
ճྫɿ ͤ͗͢ͳ͍ݪଇʹै͍ɺ࣮ࡍͷ όϦσʔγϣϯϢʔβʔʹͤΔɺ ϥΠϒϥϦόϦσʔγϣϯఆٛͷ ϑοΫDSLͷΈఏڙ
۩ମྫ ʢࠓճͷυϝΠϯίϚϯυύλʔϯʣ
NecoϏδωεϩδοΫΛ ʮίϚϯυʯʹׂ͠ɺ ͦΕΒΛΈ߹ΘͤΔϑϩʔΛ ࢧԉ͢ΔϥΠϒϥϦ
·ͱΊ • ͔ͤͬ͘RubyͰॻ͍ͯΔΜ͔ͩΒΠϯλʔϑΣΠεʹͩ͜Θ Γ͍ͨʢָ͍ͬͯ͠ϥΠϒϥϦ͕΄͍͠ʣ • DSLRubyͷڧΈͰ͋Γɺదʹ໋໊ɾ࣮͢Ε୯७ͳϝ ιουΑΓॊೈͳఆٛΠϯλʔϑΣΠεΛఏڙͰ͖Δ • ͕Μͬͯॊೈͳ͍উखΛࢦͯ͠ΔͷͰNecoͬͯ͘ΕΑͳʢએʣ