Your SlideShare is downloading. ×
Os Alrubaie Ruby
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Os Alrubaie Ruby

353
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
353
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Practical Considerations for DSLs in Ruby Muness Alrubaie muness@gmail.com muness.blogspot.com ThoughtWorks www.thoughtworks.com
  • 2. ? Ask!
  • 3. What are we going to talk about?
  • 4. Text A limited form of language suitable for a specific class of problems. Domain Specific Language?
  • 5. Venti half-caf, extra hot, no whip mocha DSL Example
  • 6. Route 66, swinging, easy on the chorus, extra solo at the coda, and a bump at the end. Scattered, smothered, covered. More examples
  • 7. ... languages are not so much a means of expressing truth that has already been established, but are a means of discovering truth that was previously unknown. Their diversity is a diversity not of sounds and signs but of ways of looking at the world. Why?
  • 8. Declarative Programming
  • 9. External vs. Internal
  • 10. Consideration 1: Focused
  • 11. Fluent Interfaces
  • 12. Composing fluent interfaces • Named Parameters calendar.add 'a conference call', :on => 'may 3', :at => '4 PM' • Method Chaining calendar.add('a conference call').on('May 3').at('4 PM') • Nested Calls calendar.add a('conference call').on('May 3').at('4 PM')
  • 13. Consideration 2: End In Mind
  • 14. Consideration 3: DRY
  • 15. Consideration 4: Be Context Sensitive
  • 16. The fascinating thing is that, in my experience, most well-written Ruby programs are already a DSL, just by nature of Ruby’s syntax. Symbols, blocks, optional parentheses around parameters—these all go a long way toward making Ruby programs read naturally. Additionally, a well-designed application encapsulates its problem domain, which also just happens to be a good metric for determining the effectiveness of a DSL. A DSL can be thought of as (and many cases, really is) an API for your application.
  • 17. Consideration 5: Evolve into a DSL
  • 18. Considerations • Focused • Begin with the End in Mind • Don’t repeat your context • Take advantage of run-time context • Evolve your implementation into DSL
  • 19. Resources • Martin Fowler on: • Language Workbenches • Internal DSL Style • Fluent Interfaces • Writing Domain Specific Languages, Jamis Buck • Evolving an Embedded DSL in Java, Steve Freeman and Nat Pryce • Language Oriented Programming: The Next programming Paradigm, Sergey Dmitriev • Software Factories, Microsoft
  • 20. ? session evaluations Muness Alrubaie muness@gmail.com muness.blogspot.com This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 License. http://creativecommons.org/licenses/by-nc-sa/2.5/

×