SlideShare a Scribd company logo
DSL & C#
" E V E R Y T H I N G I S B E T T E R W I T H B L U E T O O T H " D S L
T H E B I G B A N G T H E O R Y
WHAT IS DSL?
• DSL – Domain Specific Language
SIMPLE EXAMPLE
WORKFLOW DSL
WORKFLOW DSL
DSL ALGORITHM VISUALIZATION
DSL FOR GUI TESTING
DSL MESS
DSL MESS FIXING
GRAPHVIZ
GRAPHVIZ
DSL PROS & CONS
PROS
• Close focus on the domain area
– Own abstractions
– Specialized Syntax (till to jargon
words)
– Tweaked errors handling
– Specific tools
CONS
• Lack of support for common things,
such as math expressions
• We need to study it
• No one wants to study bad DSLs
DSL MICRO
INTERNAL DSL
A L S O K N O W N A S E M B E D D E D D S L
EXAMPLES
C# BUILDER PATTERN
C# BUILDER PATTERN
G R A P H B U I L D E R
NB! Return types
E D G E B U I L D E R
NB!
Style Return type!
D O N E !
Graph created successfully!
REVIEW GRAPH CREATION SYNTAX
INTERNAL DSL
->
EXTERNAL DSL
M A G I C T R A N S F O R M AT I O N
NUGET THEM ALL
DYNAMIC GRAPH VERTICES QUERY
DYNAMIC EXPRESSION API
EXTERNAL DSL
REGULAR EXPRESSION EDITOR
REQUIREMENTS
• Write complex regular expressions
• Reuse regular expression parts in other regular expressions
• Test regular expressions and theirs parts
PARTS DECLARATION
COMPOSING REGULAR EXPRESSION
ADDING BLACKJACK
ADDING … ONE MORE BLACKJACK
ADDING … AND MORE
THE END. TO BE CONTINUE
Author: Dmitry Dorogoy
Emaii: dorogoj (dog) live.ru
https://dimonsmart.wordpress.com/
https://twitter.com/dimonsmart
https://www.facebook.com/DimonSmart

More Related Content

Similar to C# DSL (eng)

DSL explained _
DSL explained _DSL explained _
DSL explained _
Dmitry Kandalov
 
Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using Ruby
Netguru
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expert
Paul King
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith Ruby
ThoughtWorks
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
Lakshan Perera
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
Metamorphic Domain-Specific Languages
Metamorphic Domain-Specific LanguagesMetamorphic Domain-Specific Languages
Metamorphic Domain-Specific Languages
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Web based tool for domain specific modeling
Web based tool for domain specific modeling Web based tool for domain specific modeling
Web based tool for domain specific modeling
PG Scholar
 
Interactive DSML Design
Interactive DSML DesignInteractive DSML Design
Interactive DSML Design
Andriy Levytskyy
 
BDD by example
BDD by exampleBDD by example
BDD by example
Xavier Fornés Arrabal
 
Seamless semantics - avoiding semantic discontinuity
Seamless semantics - avoiding semantic discontinuitySeamless semantics - avoiding semantic discontinuity
Seamless semantics - avoiding semantic discontinuity
Steffen Staab
 
Dsl overview
Dsl overviewDsl overview
Dsl overviewClarkTony
 
High quality Front-End
High quality Front-EndHigh quality Front-End
High quality Front-End
David Simons
 
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy MetaprogrammingBuilding DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Skills Matter
 
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...elliando dias
 
DSL Best Practices
DSL Best PracticesDSL Best Practices
DSL Best Practices
Markus Voelter
 
E3 chap-16
E3 chap-16E3 chap-16
E3 chap-16
Welly Dian Astika
 
Data Normalization and Alignment in Heterogeneous Data Sets
Data Normalization and Alignment in Heterogeneous Data SetsData Normalization and Alignment in Heterogeneous Data Sets
Data Normalization and Alignment in Heterogeneous Data SetsDataCards
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-Side
ASIMYILDIZ
 
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
Harshal Hayatnagarkar
 

Similar to C# DSL (eng) (20)

DSL explained _
DSL explained _DSL explained _
DSL explained _
 
Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using Ruby
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expert
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith Ruby
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
Metamorphic Domain-Specific Languages
Metamorphic Domain-Specific LanguagesMetamorphic Domain-Specific Languages
Metamorphic Domain-Specific Languages
 
Web based tool for domain specific modeling
Web based tool for domain specific modeling Web based tool for domain specific modeling
Web based tool for domain specific modeling
 
Interactive DSML Design
Interactive DSML DesignInteractive DSML Design
Interactive DSML Design
 
BDD by example
BDD by exampleBDD by example
BDD by example
 
Seamless semantics - avoiding semantic discontinuity
Seamless semantics - avoiding semantic discontinuitySeamless semantics - avoiding semantic discontinuity
Seamless semantics - avoiding semantic discontinuity
 
Dsl overview
Dsl overviewDsl overview
Dsl overview
 
High quality Front-End
High quality Front-EndHigh quality Front-End
High quality Front-End
 
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy MetaprogrammingBuilding DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
 
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...
Exploiting JRuby: Building Domain-Specific Languages for the Java Virtual Mac...
 
DSL Best Practices
DSL Best PracticesDSL Best Practices
DSL Best Practices
 
E3 chap-16
E3 chap-16E3 chap-16
E3 chap-16
 
Data Normalization and Alignment in Heterogeneous Data Sets
Data Normalization and Alignment in Heterogeneous Data SetsData Normalization and Alignment in Heterogeneous Data Sets
Data Normalization and Alignment in Heterogeneous Data Sets
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-Side
 
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
 

More from Dmitry Dorogoy

Like SpecFlow
Like SpecFlowLike SpecFlow
Like SpecFlow
Dmitry Dorogoy
 
C Sharp String.pptx
C Sharp String.pptxC Sharp String.pptx
C Sharp String.pptx
Dmitry Dorogoy
 
C sharp mash up
C sharp mash upC sharp mash up
C sharp mash up
Dmitry Dorogoy
 
DSL with C# easy start
DSL with C# easy startDSL with C# easy start
DSL with C# easy start
Dmitry Dorogoy
 
фотоFun
фотоFunфотоFun
фотоFun
Dmitry Dorogoy
 
Multi rotor
Multi rotorMulti rotor
Multi rotor
Dmitry Dorogoy
 
Добро пожаловать в удобный мир
Добро пожаловать в удобный мирДобро пожаловать в удобный мир
Добро пожаловать в удобный мир
Dmitry Dorogoy
 

More from Dmitry Dorogoy (7)

Like SpecFlow
Like SpecFlowLike SpecFlow
Like SpecFlow
 
C Sharp String.pptx
C Sharp String.pptxC Sharp String.pptx
C Sharp String.pptx
 
C sharp mash up
C sharp mash upC sharp mash up
C sharp mash up
 
DSL with C# easy start
DSL with C# easy startDSL with C# easy start
DSL with C# easy start
 
фотоFun
фотоFunфотоFun
фотоFun
 
Multi rotor
Multi rotorMulti rotor
Multi rotor
 
Добро пожаловать в удобный мир
Добро пожаловать в удобный мирДобро пожаловать в удобный мир
Добро пожаловать в удобный мир
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 

C# DSL (eng)

Editor's Notes

  1. DSL – Domain Specific Language. Another words – language specifically designed for specific scope. Unlike most general-purpose programming languages that are familiar to all, specialized languages have a very narrow focus.
  2. The simplest examples of DSL are: SQL - a database-specific language, Air tickets search-search language, etc.
  3. Often, the desire to create a specific tool for a specific area results in the construction of a graphic editor to indicate connections and relationships. In many cases, this approach is very good, but not at all.
  4. Sometimes the desire to add a little graphics to something very similar to the general purpose language begins to compete with common sense. Notice how much more complex the definition of a simple condition has become. If you decided to implement DSL in your project. It must be profitable. In other words do not do graphical DSL only because other do it. In case shown – the graphical representation is a complete disaster. It not only make a mess but is consume more space then direct English condition (if then else). Simple off topic. Do you know why Microsoft tiles menu with life tiles is not always good idea? IMHO the main disadvantage is impossibility to remember application icon. For example for photos application. Why I remember this? The graphical representation for DSL not always a bad idea. But remember the goal of this presentation. One of possible goals is simple presentation for complicated things. Have you ever seen a wall near a database developer? What is on that wall? A database diagram! And database developer could always remember where Clients database located. Developer used his visual memory and imagination to visualize a huge database structure. And in this case graphical representation – is a deal. But! One simple thought. What happened if you rearrange tables on this DB diagram and put it back to the wall?
  5. But in some cases, visualization can be useful. For example, to show high-level diagrams, or algorithms block-scheme.
  6. Another very good example of DSL – is graphical and text combined DSL. It looks like a “visual sugar” but I think it’s more then just a sugar. This algorithm representation change the way of thinking about algorithm. Try to imagine this example without images. Is it the same DSL? I suppose – no.
  7. Often DSL is not just a language, but a language tied to a specific development environment. For example, it is very convenient to use the programming language to debug electrical circuits, with hints about the pin assignment. But does the diagram in the middle make the language clearer than the text? And next discussion point – what do you think about complexity? Is it easier to support both text and graphical representation then only one of them? And what about equivalence? Is it always possible to represent graphically any program text and vice versa?
  8. Speaking about different DSL representations it is impossible not to mention the need to transform between representations. And some development environments provide this function. Usually this is only a one way road. May be many of you remember html file and browser window. This is a good example of one way transformation between text and graphical represntations.
  9. A very good example of DSL is the language of graph description.
  10. Don't think it's a very primitive language. At due diligence, it will be very powerful tool.
  11. Cons and pros. I hope all points is clear enough. I want you to focus on “support for common things”
  12. This is a screenshot of the very popular graphic editor - CorelDraw. Note how easy it is to divide page size by 2. This is the same as fold paper sheet. Or add 10 mm to a page border. It’s sometime needed for magazine prepress operations. You also could easily transform between different units of measurement and do simple mathematical operations. And Yes! It's a small, but very powerful and useful DSL.
  13. An internal DSL is a DSL based on a general purpose programming language. In fact, it is just a very well-designed library, which hides language specific details and show domain specific object and functions to the user. it's not a 100% accurate description but for now it’s ok. Let's take an example of how you can implement a small piece of internal DSL. As an example, let's take the graph description language.
  14. Let's describe the classes in our subject area. Vertex. It’ll be described only with Label just for simplicity.
  15. Graph edges. We assume that our graph is oriented. So we describe edges as From and To vertex, and edge style. For simplicity we treat Style just as string.
  16. And now let’s apply the popular builder pattern. In our case, it fits just perfect. For those who are not familiar with the pattern - pay attention to class return types. I used two approaches here for demonstrate both. In the first case, the class returns itself. And in the second case, the class returns another builder-class.
  17. The second builder contains the edge creation features. And the latest function sets the edge style and returns the previous builder. This function could be spited into two. One sets the style and the other completes the edge creation and returns the previous builder.
  18. As a result, we created a graph using syntax specifically focused on graph creation.
  19. Let’s review graph creation syntax. You could hardly find C# here. It looks like special graph creation language, Of course we see a typical C# function chain syntax. But show this to your school geometry teacher. I expect everything will be understandable.
  20. It's all good, but it was an internal DSL. Of course, this syntax is nice to use. And now you could create any graphs with simple builder syntax. Next goal is search through the graph. In other word let’s try to give uses a function to search through the already created graph without digging into C# programming environment. And now you can do a simple but very spectacular trick! NB! We just switch a target goal just for demo. Similar trick could be used for graph creation.
  21. First thing we need is a System.Linq.Dynamic nuget package
  22. And now look how we could use an internal and external DSL side by side. In the first example we filter vertices by Key which contains the letter ‘e’. Our Graph class contains vertices dictionary, so we use Key. It’s easy to get rid of this just by exposing a Vertices collection with a specially designed public property. And look at the second example. We simulate user input as the userInput variable. And this variable contains exactly the same expression we used in the first code part. And final action – we compare these two approaches results and get exactly the same vertices. At that moment I’m very close to my presentation goal. If you are dreaming about giving your users the ability to write some queries by themselves. Just try to give them MVP (minimal valuable product). I showed you how easily it could be done. My solution is not for a public and production, but its very fast and simple for in-house implementation and for research. You should not dive into external dsl implementation without a detailed research!
  23. In case you start thinking about sql injection or something similar, the mentioned Linq.Dynamic library gives you a solution with passing parameters into the query as parameters and not as part of string. If you are interested – just take a look.
  24. And now you are ready to hear the truth about a big, “real” DSL, It’s really complicated. It’s true. And at the same time it’s very interesting. Just for example take a look at the screenshot. You can see a C# based library with a beautiful name Irony. And at the left window you can see a simple C# program. At the right window you can find a parsing tree for this program, It seems big, but if you carefully look through line by line you will find it easy to understand. At the first sight it’s a bit verbose. But it only depends on the grammar complexity and variability. Your own grammar may look more simple. My presentation’s goal is not to dive deep into real grammars and parsers. I just want to inspire you to look at DSL’s and try.
  25. Now it’s time to show you a real and sophisticated DSL sample. This sample is a visual regular expression editor with Black Jack and own regular expression syntax!
  26. Let me explain the initial requirements. First of all we need to test a regular expression against a list of samples. Both positive and negative samples. We might want to extend these samples by some expressions just for exploration without marking them as positive or negative. Second, we need building blocks for composing complex regular expressions. And we would like to test these building blocks separately.
  27. Let me describe an regular expression part syntax. It is a declaration with name and regular expression text. Note that I use a freeform expression format that allows me to arrange regular expression by lines and provide comments for separate lines if needed. On the slide I declare two building blocks. The first is for Number named (try to guess ) Number, And the second one is for event name having two forms. Short form ”DevDay” or long form “DeveloperDay”. At this moment I have only building blocks. My next step is to compose a whole regular expression.
  28. Just for a simple demonstration I suppose that we want to match number and event name or name and number. Pay your attention at the screenshot. It looks quite simple and readable. At this moment my regular expression syntax is more powerful than many others. But where is a Black Jack?
  29. Now it’s time to add a syntax for testing the regular expressions. A good example of syntax extension is embedding tests into the syntax. The Accept keyword is for texts that must be matched. Reject - for texts that should not be matched. And Sample – for a text we just want to track for curiosity. It looks like a real black jack. And now it is time for …. Another black jack 
  30. We want more than just to see our tests status. We also want to see the exact matched text. Cool? If not, we can even see a predicted execution time and the complexity of the resulted regular expression. By the way, there can be some pathological regular expressions that perform very slowly and with a significant memory consumption. And the difference between normal and pathological regular expressions may be just with one symbol! So it’s important to not only know the matching status but also the matching speed. Speed? You should note how I measure the matching speed only for short samples. It’s useful for edge cases. But what about a normal flow?
  31. It’s my DSL and I can improve it! Testing speed of the short samples is a good idea but we can do even better. I’ve added a testing against some typical patterns, English text, Numbers (spreadsheet simulation), mixed text and numbers and something close to random binary file.
  32. Feel free to contact me. If I’m not answering just try twitter 