SlideShare a Scribd company logo
DSL & C#
Л Ю Б А Я В Е Щ Ь С Т А Н О В И ТС Я Л У Ч Ш Е C
B L U E TO OT H D S L
ЧТО ТАКОЕ DSL?
• DSL – Domain Specific Language
ПРИМЕРЫ
WORKFLOW DSL
WORKFLOW DSL
DSL ALGORITHM VISUALIZATION
DSL FOR GUI TESTING
DSL MESS
DSL MESS FIXING
GRAPHVIZ
• DOT – A DSL to define graphs
GRAPHVIZ
PROS & CONS
PROS
• Жёсткая концентрация на предметной
области:
– Собственные абстракции
– Синтаксис
– Диагностика ошибок
– Утилиты
CONS
• Отсутствие (необходимость
самостоятельного изготовления)
поддержки общепринятых вещей
• Нужно учить
• Если сделать плохо – учить никто не
будет
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!
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 expression with test capabilities
• Test regular expression parts separately
• Reuse regular expression parts in other regular expressions
PARTS DECLARATION
COMPOSING REGULAR EXPRESSION
ADDING BLACKJACK
ADDING … ONE MORE BLACKJACK
ADDING … AND MORE

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

DSL with C# easy start

Editor's Notes

  1. DSL – это Domain Specific Language. Т.е. язык специфический для области применения. В отличие от большинства знакомых всем языков программирования общего назначения, специализированные языки имеют очень узкую направленность.
  2. Простейшими примерами DSL являются: SQL – язык специфичный для баз данных, Язык запросов для поиска авиабилетов и т.п.
  3. Часто желание создать специфический инструмент для конкретной области выливается в построение графического редактора для обозначения связей и отношений. Во многих случаях данный подход очень хорош, но не во всех.
  4. Иногда желание добавить немного графики в нечто очень похожее на язык общего назначения начинает соседствовать со здравым смыслом. Обратите внимание на то насколько более громоздким стало определение банального условия
  5. Но в некоторых случаях визуализация может быть полезна. Например для демонстрации диаграмм высокого уровня. Или блок схем алгоритмов.
  6. Часто DSL это не просто язык, но язык привязанный к конкретной среде разработки. Например, очень удобно использовать для отладки электрических схем язык программирования, с подсказками о назначении выводом микросхем. Но вот делает ли схема в середине язык понятнее чем текст?
  7. Говоря о том, что зачастую DSL имеет не только текстовое но и графическое отображение. Нельзя не упомянуть о желании иногда видеть текст, а иногда графику. И некоторые среды разработки предоставляют возможность преобразования между представлениями.
  8. Очень хороший пример DSL – это язык описания графов.
  9. Не надо думать, что это очень примитивный язык. При должном умении он способен на очень многое.
  10. За и против для DSL. Тут всё понятно. Но остановимся чуть подробнее на необходимости заново самостоятельно делать общепринятые вещи.
  11. Это скриншот графического редактора CorelDraw. Обратите внимание, на то как просто реализована возможность поделить размер страницы на 2 или прибавить к странице поля в 10 мм. И да! Это маленький но вполне себе DSL. С поддержкой преобразований различных единиц измерения и простейших математических операций.
  12. Внутренний DSL – это DSL, построенный на базе языка программирования общего назначения. По сути – это просто очень хорошо спроектированная библиотека, которая прячет от пользователя особенности реализующего её языка. Рассмотрим на примере, как можно реализовать маленький кусочек внутреннего DSL. В качестве примера возьмём язык описания графов.
  13. Описываем классы нашей предметной области. Вершина.
  14. Ребро графа.
  15. А сейчас применим популярный паттерн строитель. В данном случае он подходит просто идеально. Для тех кто не знаком с паттерном – обратите внимание на то, какой класс возвращает строитель. Для примера здесь использовано два подхода. В первом случае класс возвращает сам себя. А во втором случае класс возвращает другого строителя.
  16. Этот второй строитель в свою очередь содержит функции создания ребра и последнюю завершающую функцию, которая устанавливает стиль отображения ребра и возвращает предыдущего строителя. Последняя функция может быть при желании разбита на две. Одна устанавливает стиль а вторая завершает построение ребра и возвращает предыдущего строителя.
  17. В итоге мы создали граф применяя синтаксис специально ориентированный на создание графов.
  18. Всё хорошо, но ведь это был внутренний DSL. Конечно же такой синтаксис приятно использовать но написание хорошей коллекции строителей может быть затратно. И вот тут можно сделать небольшой но очень эффектный трюк!