SlideShare una empresa de Scribd logo
1 de 18
Domain Specific Languages Dror Helper
About.Me Software developer  Blogger (http://blog.drorhelper.com) Language geek
What do they mean? Bug Feature Release Candidate Show stopper “The next release candidate would contain features X, Y & Z and no more than 5 high priority Bugsandno show stoppers”
Agenda Why should I use DSLs Domain Specific Languages Fluent interface
Domain Specific Languages created specifically to solve problems in a particular domain Layer of abstraction on top of an existing domain model Can be used by domain experts
DSL classification External vs. Internal Textual vs. Graphic
Graphical DSLs
External DSLs SELECTBook.title, count(*) ASAuthors FROMBook JOINBook_authorONBook.isbn = Book_author.isbnGROUPBYBook.title; <([A-Z][A-Z0-9]*)[^>]*>(.*?)</> buyIBM @ 100 forNOMURA sellGOOGLE @ limitprice= 70 for CHASE
Internal DSLs Built on top of an existing language Use languages like Ruby, Python, BOO
Fluent interfaces coined by Eric Evans and Martin Fowler An OOP API that aims to provide readable code Use method chaining an pass context via return value ,[object Object]
DateTime.Now.AddDays(7);  DateTime.Now.AddWeeks(1);,[object Object]
Fluent Interface design Hide your working. Keep your state to yourself. Think really hard about names. Take advantage of your implementation language. If you have them, blocks are you friends. Test first design can be a useful way of exploring what your interface should be. Reasonable defaults.
Tips & Tricks  Use Interfaces Return different interface to change functionality Generics are handy if user need to specify type Lambda and delegates for custom functionality
Books DSLs in Action DSLs in Boo
The shopping cart	 A Domain Specific exercise
The Story You need to create a simple rule engine that would enable developers to add custom rules to the company’s Shopping cart application.
The engine Three customer types: regular, preferred & VIP Customer the following fields:  name  address date of birth The system tracks the customer’s purchases (date, amount) Products can be on Sale (discount) Discount changes according to rules Each rule must have a customer type
Usage examples A VIP customer get 15% discount on all purchases Buying product A would give you 10% discount on product B Preferred and VIP customers can buy 5 + 1 of a specific product All customers can get 20% off purchase using specific coupon If amount of purchase > 100$ customer is entitled for 10% discount. If customer have purchased > 100$ the last three months upgrade him to VIP On the customer’s birthday he’s entitled to 50% discount All customers living in New York can get up to 25% off all purchases

Más contenido relacionado

Destacado

Destacado (11)

Introduction to Agile & scrum
Introduction to Agile & scrumIntroduction to Agile & scrum
Introduction to Agile & scrum
 
Infrastructure code in Agile software development
Infrastructure code in Agile software developmentInfrastructure code in Agile software development
Infrastructure code in Agile software development
 
Scrum intro
Scrum intro Scrum intro
Scrum intro
 
Scrum training day 2
Scrum training day 2Scrum training day 2
Scrum training day 2
 
Scrum training day 1
Scrum training day 1Scrum training day 1
Scrum training day 1
 
Less intro workshop
Less intro workshopLess intro workshop
Less intro workshop
 
Lean sw development il tech-talks
Lean sw development   il tech-talksLean sw development   il tech-talks
Lean sw development il tech-talks
 
Agile estimation and planning
Agile estimation and planning Agile estimation and planning
Agile estimation and planning
 
Practical-Agile Product owner workshop
Practical-Agile Product owner workshopPractical-Agile Product owner workshop
Practical-Agile Product owner workshop
 
Advanced Scrum master workshop
Advanced Scrum master workshopAdvanced Scrum master workshop
Advanced Scrum master workshop
 
Get rid of boring retrospectives
Get rid of boring retrospectivesGet rid of boring retrospectives
Get rid of boring retrospectives
 

Similar a Domain specific languages

Ahrefs SEO Toolset Quick Guide ( Updated in August 2013)
Ahrefs SEO Toolset Quick Guide  ( Updated in August 2013) Ahrefs SEO Toolset Quick Guide  ( Updated in August 2013)
Ahrefs SEO Toolset Quick Guide ( Updated in August 2013)
Clare Hoang
 

Similar a Domain specific languages (20)

Website development proposal - Leadtrance Technologies
Website development proposal - Leadtrance TechnologiesWebsite development proposal - Leadtrance Technologies
Website development proposal - Leadtrance Technologies
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Salesforce CPQ by yuvaraj
Salesforce CPQ by yuvarajSalesforce CPQ by yuvaraj
Salesforce CPQ by yuvaraj
 
Front-End Performance Checklist 2020
Front-End Performance Checklist 2020Front-End Performance Checklist 2020
Front-End Performance Checklist 2020
 
Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven Design
 
SMX West 2012 - Duplication, Aggregation, Syndication, Affiliates, Scraping &...
SMX West 2012 - Duplication, Aggregation, Syndication, Affiliates, Scraping &...SMX West 2012 - Duplication, Aggregation, Syndication, Affiliates, Scraping &...
SMX West 2012 - Duplication, Aggregation, Syndication, Affiliates, Scraping &...
 
SBF STEALTH (en)
SBF STEALTH (en)SBF STEALTH (en)
SBF STEALTH (en)
 
Ahrefs SEO Toolset Quick Guide ( Updated in August 2013)
Ahrefs SEO Toolset Quick Guide  ( Updated in August 2013) Ahrefs SEO Toolset Quick Guide  ( Updated in August 2013)
Ahrefs SEO Toolset Quick Guide ( Updated in August 2013)
 
Sage X3 Sales App: Gain Mobile Access to Sage X3
Sage X3 Sales App: Gain Mobile Access to Sage X3Sage X3 Sales App: Gain Mobile Access to Sage X3
Sage X3 Sales App: Gain Mobile Access to Sage X3
 
Internal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional TestingInternal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional Testing
 
IBM Forms Experience Builder on Cloud
IBM Forms Experience Builder on Cloud IBM Forms Experience Builder on Cloud
IBM Forms Experience Builder on Cloud
 
SDWest2005Goetsch
SDWest2005GoetschSDWest2005Goetsch
SDWest2005Goetsch
 
Local edge
Local edgeLocal edge
Local edge
 
Wordpress org support_topic_displaying_phone_numbers
Wordpress org support_topic_displaying_phone_numbersWordpress org support_topic_displaying_phone_numbers
Wordpress org support_topic_displaying_phone_numbers
 
AI Builder Deepdive DynamicsPower! Brussels 2019
AI Builder Deepdive DynamicsPower! Brussels 2019AI Builder Deepdive DynamicsPower! Brussels 2019
AI Builder Deepdive DynamicsPower! Brussels 2019
 
Versioned Page Objects: How to handle 12 versions of web application
Versioned Page Objects: How to handle 12 versions of web applicationVersioned Page Objects: How to handle 12 versions of web application
Versioned Page Objects: How to handle 12 versions of web application
 
Responsive Web Design Basics
Responsive Web Design BasicsResponsive Web Design Basics
Responsive Web Design Basics
 
How to reduce DTP and translation costs with FrameMaker
How to reduce DTP and translation costs with FrameMakerHow to reduce DTP and translation costs with FrameMaker
How to reduce DTP and translation costs with FrameMaker
 
Conga composer
Conga composerConga composer
Conga composer
 
Select an e forms vendor
Select an e forms vendorSelect an e forms vendor
Select an e forms vendor
 

Más de Dror Helper

Más de Dror Helper (20)

Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
 
Debugging with visual studio beyond 'F5'
Debugging with visual studio beyond 'F5'Debugging with visual studio beyond 'F5'
Debugging with visual studio beyond 'F5'
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
A software developer guide to working with aws
A software developer guide to working with awsA software developer guide to working with aws
A software developer guide to working with aws
 
The secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you aboutThe secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you about
 
The role of the architect in agile
The role of the architect in agileThe role of the architect in agile
The role of the architect in agile
 
Harnessing the power of aws using dot net core
Harnessing the power of aws using dot net coreHarnessing the power of aws using dot net core
Harnessing the power of aws using dot net core
 
Developing multi-platform microservices using .NET core
 Developing multi-platform microservices using .NET core Developing multi-platform microservices using .NET core
Developing multi-platform microservices using .NET core
 
Harnessing the power of aws using dot net
Harnessing the power of aws using dot netHarnessing the power of aws using dot net
Harnessing the power of aws using dot net
 
Secret unit testing tools no one ever told you about
Secret unit testing tools no one ever told you aboutSecret unit testing tools no one ever told you about
Secret unit testing tools no one ever told you about
 
C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the ugly
 
Working with c++ legacy code
Working with c++ legacy codeWorking with c++ legacy code
Working with c++ legacy code
 
Visual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should knowVisual Studio tricks every dot net developer should know
Visual Studio tricks every dot net developer should know
 
Secret unit testing tools
Secret unit testing toolsSecret unit testing tools
Secret unit testing tools
 
Electronics 101 for software developers
Electronics 101 for software developersElectronics 101 for software developers
Electronics 101 for software developers
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbg
 

Último

Último (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Domain specific languages

  • 2. About.Me Software developer Blogger (http://blog.drorhelper.com) Language geek
  • 3. What do they mean? Bug Feature Release Candidate Show stopper “The next release candidate would contain features X, Y & Z and no more than 5 high priority Bugsandno show stoppers”
  • 4. Agenda Why should I use DSLs Domain Specific Languages Fluent interface
  • 5. Domain Specific Languages created specifically to solve problems in a particular domain Layer of abstraction on top of an existing domain model Can be used by domain experts
  • 6. DSL classification External vs. Internal Textual vs. Graphic
  • 8. External DSLs SELECTBook.title, count(*) ASAuthors FROMBook JOINBook_authorONBook.isbn = Book_author.isbnGROUPBYBook.title; <([A-Z][A-Z0-9]*)[^>]*>(.*?)</> buyIBM @ 100 forNOMURA sellGOOGLE @ limitprice= 70 for CHASE
  • 9. Internal DSLs Built on top of an existing language Use languages like Ruby, Python, BOO
  • 10.
  • 11.
  • 12. Fluent Interface design Hide your working. Keep your state to yourself. Think really hard about names. Take advantage of your implementation language. If you have them, blocks are you friends. Test first design can be a useful way of exploring what your interface should be. Reasonable defaults.
  • 13. Tips & Tricks Use Interfaces Return different interface to change functionality Generics are handy if user need to specify type Lambda and delegates for custom functionality
  • 14. Books DSLs in Action DSLs in Boo
  • 15. The shopping cart A Domain Specific exercise
  • 16. The Story You need to create a simple rule engine that would enable developers to add custom rules to the company’s Shopping cart application.
  • 17. The engine Three customer types: regular, preferred & VIP Customer the following fields: name address date of birth The system tracks the customer’s purchases (date, amount) Products can be on Sale (discount) Discount changes according to rules Each rule must have a customer type
  • 18. Usage examples A VIP customer get 15% discount on all purchases Buying product A would give you 10% discount on product B Preferred and VIP customers can buy 5 + 1 of a specific product All customers can get 20% off purchase using specific coupon If amount of purchase > 100$ customer is entitled for 10% discount. If customer have purchased > 100$ the last three months upgrade him to VIP On the customer’s birthday he’s entitled to 50% discount All customers living in New York can get up to 25% off all purchases

Notas del editor

  1. An internal DSL is one that uses the infrastructure of an existing programming language(also called the host language of the DSL) to build domain-specific semanticson top of it. One of the most popular internal DSLs used today is Rails, which is implementedon top of the Ruby programming language. When you write Rails code,you’re programming in Ruby, based on the semantics that Rails implements for developingweb applications. In most cases, an internal DSL is implemented as a library ontop of the existing host language.An external DSL is one that’s developed ground-up and has separate infrastructure forlexical analysis, parsing techniques, interpretation, compilation, and code generation.Developing an external DSL is similar to implementing a new language fromscratch with its own syntax and semantics. Build tools like make, parser generators likeYACC, and lexical analysis tools like LEX are examples of popular external DSLs.
  2. Fromhttp://en.wikipedia.org/wiki/Fluent_interface