SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
1
Sprache als Werkzeug
DSLs mit Kotlin
@toddquackenbush on Unsplash
@maverick_1601
Frank Scheffler
2
DSLs in Kotlin
https://kotlinlang.org/docs/reference/type-safe-builders.html
3
Domain Specific Languages: Definition
“DSLs are small languages, focused on a
particular aspect of a software system.
You can't build a whole program with a DSL,
but you often use multiple DSLs in a
system mainly written in a general purpose
language.”
- Martin Fowler with Rebecca Parsons
https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
4
Domain Specific Languages: Definition
“DSLs come in two main forms: external
and internal. An external DSL is a language
that's parsed independently of the host
general purpose language: good examples
include regular expressions and CSS.”
- Martin Fowler with Rebecca Parsons
https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
5
Domain Specific Languages: Definition
“Internal DSLs are a particular form of API
in a host general purpose language, often
referred to as a fluent interface. The way
mocking libraries, such as JMock, define
expectations for tests are good examples
of this.”
- Martin Fowler with Rebecca Parsons
https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
6
Kotlin Internal DSL Selection
Gradle Kotlin DSL
https://github.com/gradle/kotlin-dsl
Beans/Router/MockMvc DSL
https://github.com/spring-projects/spring-framework
Kotlin Test
https://github.com/kotlintest/kotlintest
Kuery SQL in Kotlin
https://www.kotlinresources.com/library/kuery/
Spring Fu Microframework
https://github.com/spring-projects/spring-fu
GeoJSON Builder DSL
https://github.com/dxfrontiers/kotlin-geojson-dsl
7
1. Predictable
Domain logic is expressed declaratively, while execution is controlled by the DSL.
2. Safer
Restricted dialect and clearer scoping reduces unsafe operations.
3. More expressive
Domain code clearly expresses what should be done. Domain specific errors are easier to understand.
4. Portable
Domain logic execution can be ported to new platforms, if necessary.
5. Easier to understand
Domain experts are able to learn the DSL in less time.
DSL Advantages
8
Building Blocks for DSLs in Kotlin 1/2
Simplified Lambda Syntax
Extension Functions
9
Building Blocks for DSLs in Kotlin 2/2
Lambdas with Receiver
Operator Overloading
10
A Gherkin Test DSL
“Gherkin uses a set of special
keywords to give structure
and meaning to executable
specifications.”
- Cucumber
GIVEN
state before
behavior is
applied
WHEN
specifies the
behavior part
THEN
defines changes
or expected
outcome
11
The Calculator: Classical Verification
12
The Calculator: Gherkin-Style Verification
“given”-Lambda
yields the test
subject
“when”-Lambda receives
test subject and returns
test execution result
“then”-Lambda receives
an assertion object
wrapping the test result
13
Gherkin DSL: Capturing the “test setup”
14
Gherkin DSL: Capturing the “execution result”
15
Gherkin DSL: Triggering test and verification
16
Gherkin DSL: Extensibility
optional assertion
chaining
repeated/parallel
test execution
repeated/clean test
subject creation
17
The infamous Greeter
18
Using Infix Extension Functions
19
Scoping Infix Extension Functions
20
Providing type-safe Asserters
21
Almost unlimited possibilities ...
Some homework
for you!
22
Kotlin DSL Building Blocks
1. Capturing declarations/logic using Lambdas
2. Providing Declarative Context using Lambdas with Receiver
3. Providing scoped (extension) functions
4. Improving Readability using infix notation
5. (Operator overloading)
23
What’s the next DSL you’ll be designing?
Sprache als Werkzeug
DSLs mit Kotlin
https://github.com/dxfrontiers/kotlin-gherkin-dsl/tree/kkon
https://www.heise.de/developer/artikel/Sprache-als-Werkzeug-DSLs-mit-Kotlin-bauen-4599797.html
https://blog.digitalfrontiers.de
@maverick_1601
https://github.com/maverick1601
https://bit.ly/2EDAagi
Frank Scheffler

Mais conteúdo relacionado

Mais procurados

Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...
Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...
Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...Brent Salisbury
 
Introduction to YANG data models and their use in OpenDaylight: an overview
Introduction to YANG data models and their use in OpenDaylight: an overviewIntroduction to YANG data models and their use in OpenDaylight: an overview
Introduction to YANG data models and their use in OpenDaylight: an overviewCisco DevNet
 
How to Reduce Database Load with Sparse Branches
How to Reduce Database Load with Sparse BranchesHow to Reduce Database Load with Sparse Branches
How to Reduce Database Load with Sparse BranchesPerforce
 
Enterprise Software Architecture styles
Enterprise Software Architecture stylesEnterprise Software Architecture styles
Enterprise Software Architecture stylesAraf Karsh Hamid
 
DEVNET-1006 Getting Started with OpenDayLight
DEVNET-1006	Getting Started with OpenDayLightDEVNET-1006	Getting Started with OpenDayLight
DEVNET-1006 Getting Started with OpenDayLightCisco DevNet
 
Managing Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub EraManaging Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub EranexB Inc.
 
The Fn Project by Jesse Butler
 The Fn Project by Jesse Butler The Fn Project by Jesse Butler
The Fn Project by Jesse ButlerOracle Developers
 
Serverless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupServerless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupWayne Scarano
 
LAB - Component Based Development
LAB - Component Based DevelopmentLAB - Component Based Development
LAB - Component Based DevelopmentPerforce
 
2.3 (Architecture) Moving to Managed Code
2.3   (Architecture) Moving to Managed Code2.3   (Architecture) Moving to Managed Code
2.3 (Architecture) Moving to Managed CodeMicro Focus
 
Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Sid Anand
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiThoughtWorks
 
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for DevelopersBIOVIA
 
nexB Software Audit M&A: What to expect as a Seller
nexB Software Audit M&A: What to expect as a SellernexB Software Audit M&A: What to expect as a Seller
nexB Software Audit M&A: What to expect as a SellernexB Inc.
 
Code Review with Sonar
Code Review with SonarCode Review with Sonar
Code Review with SonarMax Kleiner
 
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский Sigma Software
 

Mais procurados (20)

Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...
Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...
Augmenting Flow Operations and Feedback on the Model Driven MD_SAL Approach i...
 
Introduction to YANG data models and their use in OpenDaylight: an overview
Introduction to YANG data models and their use in OpenDaylight: an overviewIntroduction to YANG data models and their use in OpenDaylight: an overview
Introduction to YANG data models and their use in OpenDaylight: an overview
 
How to Reduce Database Load with Sparse Branches
How to Reduce Database Load with Sparse BranchesHow to Reduce Database Load with Sparse Branches
How to Reduce Database Load with Sparse Branches
 
EF Core (RC2)
EF Core (RC2)EF Core (RC2)
EF Core (RC2)
 
Enterprise Software Architecture styles
Enterprise Software Architecture stylesEnterprise Software Architecture styles
Enterprise Software Architecture styles
 
DEVNET-1006 Getting Started with OpenDayLight
DEVNET-1006	Getting Started with OpenDayLightDEVNET-1006	Getting Started with OpenDayLight
DEVNET-1006 Getting Started with OpenDayLight
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Go programming language
Go programming languageGo programming language
Go programming language
 
Managing Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub EraManaging Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub Era
 
The Fn Project by Jesse Butler
 The Fn Project by Jesse Butler The Fn Project by Jesse Butler
The Fn Project by Jesse Butler
 
Serverless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupServerless Boston @ Oracle Meetup
Serverless Boston @ Oracle Meetup
 
LAB - Component Based Development
LAB - Component Based DevelopmentLAB - Component Based Development
LAB - Component Based Development
 
2.3 (Architecture) Moving to Managed Code
2.3   (Architecture) Moving to Managed Code2.3   (Architecture) Moving to Managed Code
2.3 (Architecture) Moving to Managed Code
 
Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)Netflix's Transition to High-Availability Storage (QCon SF 2010)
Netflix's Transition to High-Availability Storage (QCon SF 2010)
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagi
 
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers
(ATS3-DEV04) Introduction to Pipeline Pilot Protocol Development for Developers
 
Perl-Critic
Perl-CriticPerl-Critic
Perl-Critic
 
nexB Software Audit M&A: What to expect as a Seller
nexB Software Audit M&A: What to expect as a SellernexB Software Audit M&A: What to expect as a Seller
nexB Software Audit M&A: What to expect as a Seller
 
Code Review with Sonar
Code Review with SonarCode Review with Sonar
Code Review with Sonar
 
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
RSocket — new Reactive cross-network Protocol? Олег Докука и Игорь Лозинский
 

Semelhante a Sprache als Werkzeug: DSLs mit Kotlin (JAX 2020)

Lessons Learned From Running Spark On Docker
Lessons Learned From Running Spark On DockerLessons Learned From Running Spark On Docker
Lessons Learned From Running Spark On DockerSpark Summit
 
CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinDataArt
 
Building a sdn solution for the deployment of web application stacks in docker
Building a sdn solution for the deployment of web application stacks in dockerBuilding a sdn solution for the deployment of web application stacks in docker
Building a sdn solution for the deployment of web application stacks in dockerJorge Juan Mendoza
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBlueData, Inc.
 
Building A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdBuilding A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdRoss Kukulinski
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Jakub Hajek
 
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 2009Harshal Hayatnagarkar
 
SQL Server in DevOps Town Hall Webinar
SQL Server in DevOps Town Hall WebinarSQL Server in DevOps Town Hall Webinar
SQL Server in DevOps Town Hall WebinarTravis Wright
 
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...Zahid Anwar (OCM)
 
Oracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerOracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerGuatemala User Group
 
Open arkcompiler
Open arkcompilerOpen arkcompiler
Open arkcompileryiwei yang
 
Standardizing Drupal Development Environments using Containers
Standardizing Drupal Development Environments using ContainersStandardizing Drupal Development Environments using Containers
Standardizing Drupal Development Environments using ContainersIan Carnaghan
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service ComponentsMike Willbanks
 
How to Package & Deploy Microservices
How to Package & Deploy MicroservicesHow to Package & Deploy Microservices
How to Package & Deploy MicroservicesNico Meisenzahl
 
How to Package & Deploy Microservices
How to Package & Deploy MicroservicesHow to Package & Deploy Microservices
How to Package & Deploy Microservicespanagenda
 
Agile DSL Development in Ruby
Agile DSL Development in RubyAgile DSL Development in Ruby
Agile DSL Development in Rubyelliando dias
 
DockerCon17 - Building The Super-Dynamic Demo Center
DockerCon17 - Building The Super-Dynamic Demo CenterDockerCon17 - Building The Super-Dynamic Demo Center
DockerCon17 - Building The Super-Dynamic Demo CenterMichael Wilde
 
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docx
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docxA Survey on Domain-Specific Languages for Machine.pdfA Sur.docx
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docxbartholomeocoombs
 
Lessons Learned Running Hadoop and Spark in Docker Containers
Lessons Learned Running Hadoop and Spark in Docker ContainersLessons Learned Running Hadoop and Spark in Docker Containers
Lessons Learned Running Hadoop and Spark in Docker ContainersBlueData, Inc.
 

Semelhante a Sprache als Werkzeug: DSLs mit Kotlin (JAX 2020) (20)

Api and Fluency
Api and FluencyApi and Fluency
Api and Fluency
 
Lessons Learned From Running Spark On Docker
Lessons Learned From Running Spark On DockerLessons Learned From Running Spark On Docker
Lessons Learned From Running Spark On Docker
 
CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas Kolenkin
 
Building a sdn solution for the deployment of web application stacks in docker
Building a sdn solution for the deployment of web application stacks in dockerBuilding a sdn solution for the deployment of web application stacks in docker
Building a sdn solution for the deployment of web application stacks in docker
 
Best Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker ContainersBest Practices for Running Kafka on Docker Containers
Best Practices for Running Kafka on Docker Containers
 
Building A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdBuilding A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and Etcd
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
 
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
 
SQL Server in DevOps Town Hall Webinar
SQL Server in DevOps Town Hall WebinarSQL Server in DevOps Town Hall Webinar
SQL Server in DevOps Town Hall Webinar
 
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
UKOUG Tech15 - Deploying Oracle 12c Cloud Control in Maximum Availability Arc...
 
Oracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerOracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with Docker
 
Open arkcompiler
Open arkcompilerOpen arkcompiler
Open arkcompiler
 
Standardizing Drupal Development Environments using Containers
Standardizing Drupal Development Environments using ContainersStandardizing Drupal Development Environments using Containers
Standardizing Drupal Development Environments using Containers
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service Components
 
How to Package & Deploy Microservices
How to Package & Deploy MicroservicesHow to Package & Deploy Microservices
How to Package & Deploy Microservices
 
How to Package & Deploy Microservices
How to Package & Deploy MicroservicesHow to Package & Deploy Microservices
How to Package & Deploy Microservices
 
Agile DSL Development in Ruby
Agile DSL Development in RubyAgile DSL Development in Ruby
Agile DSL Development in Ruby
 
DockerCon17 - Building The Super-Dynamic Demo Center
DockerCon17 - Building The Super-Dynamic Demo CenterDockerCon17 - Building The Super-Dynamic Demo Center
DockerCon17 - Building The Super-Dynamic Demo Center
 
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docx
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docxA Survey on Domain-Specific Languages for Machine.pdfA Sur.docx
A Survey on Domain-Specific Languages for Machine.pdfA Sur.docx
 
Lessons Learned Running Hadoop and Spark in Docker Containers
Lessons Learned Running Hadoop and Spark in Docker ContainersLessons Learned Running Hadoop and Spark in Docker Containers
Lessons Learned Running Hadoop and Spark in Docker Containers
 

Último

一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样AS
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样ayvbos
 
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec JeddahAbortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddahmarufhussain782445
 
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...ZurliaSoop
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书c6eb683559b3
 
Washington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers ShirtWashington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers Shirtrahman018755
 
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理apekaom
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理F
 
Dan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat HoodieDan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat Hoodierahman018755
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样Fi
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理F
 
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0APNIC
 
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样ayvbos
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样AS
 
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...APNIC
 
一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理AS
 
Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303Dewi Agency
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样Fi
 
一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理A
 
一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书A
 

Último (20)

一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
一比一原版(毕业证书)新加坡南洋理工学院毕业证原件一模一样
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec JeddahAbortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
Abortion Pills In Jeddah+966572737505 & Get cytotec Jeddah
 
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...
Jual obat aborsi Bekasi ( 085657271886 ) Cytote pil telat bulan penggugur kan...
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
 
Washington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers ShirtWashington Football Commanders Redskins Feathers Shirt
Washington Football Commanders Redskins Feathers Shirt
 
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理
一比一原版桑佛德大学毕业证成绩单申请学校Offer快速办理
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
 
Dan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat HoodieDan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat Hoodie
 
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
一比一原版(UWE毕业证书)西英格兰大学毕业证原件一模一样
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
APNIC Policy Roundup presented by Sunny Chendi at TWNOG 5.0
 
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样
一比一原版(USYD毕业证书)悉尼大学毕业证原件一模一样
 
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
原版定制(Glasgow毕业证书)英国格拉斯哥大学毕业证原件一模一样
 
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
Registry Data Accuracy Improvements, presented by Chimi Dorji at SANOG 41 / I...
 
一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理一比一原版英国格林多大学毕业证如何办理
一比一原版英国格林多大学毕业证如何办理
 
Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303Lowongan Kerja LC Yogyakarta Terbaru 085746015303
Lowongan Kerja LC Yogyakarta Terbaru 085746015303
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
 
一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理
 
一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书一比一定制波士顿学院毕业证学位证书
一比一定制波士顿学院毕业证学位证书
 

Sprache als Werkzeug: DSLs mit Kotlin (JAX 2020)

  • 1. 1 Sprache als Werkzeug DSLs mit Kotlin @toddquackenbush on Unsplash @maverick_1601 Frank Scheffler
  • 3. 3 Domain Specific Languages: Definition “DSLs are small languages, focused on a particular aspect of a software system. You can't build a whole program with a DSL, but you often use multiple DSLs in a system mainly written in a general purpose language.” - Martin Fowler with Rebecca Parsons https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
  • 4. 4 Domain Specific Languages: Definition “DSLs come in two main forms: external and internal. An external DSL is a language that's parsed independently of the host general purpose language: good examples include regular expressions and CSS.” - Martin Fowler with Rebecca Parsons https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
  • 5. 5 Domain Specific Languages: Definition “Internal DSLs are a particular form of API in a host general purpose language, often referred to as a fluent interface. The way mocking libraries, such as JMock, define expectations for tests are good examples of this.” - Martin Fowler with Rebecca Parsons https://images-eu.ssl-images-amazon.com/images/I/51qFZ0yIUsL.jpg
  • 6. 6 Kotlin Internal DSL Selection Gradle Kotlin DSL https://github.com/gradle/kotlin-dsl Beans/Router/MockMvc DSL https://github.com/spring-projects/spring-framework Kotlin Test https://github.com/kotlintest/kotlintest Kuery SQL in Kotlin https://www.kotlinresources.com/library/kuery/ Spring Fu Microframework https://github.com/spring-projects/spring-fu GeoJSON Builder DSL https://github.com/dxfrontiers/kotlin-geojson-dsl
  • 7. 7 1. Predictable Domain logic is expressed declaratively, while execution is controlled by the DSL. 2. Safer Restricted dialect and clearer scoping reduces unsafe operations. 3. More expressive Domain code clearly expresses what should be done. Domain specific errors are easier to understand. 4. Portable Domain logic execution can be ported to new platforms, if necessary. 5. Easier to understand Domain experts are able to learn the DSL in less time. DSL Advantages
  • 8. 8 Building Blocks for DSLs in Kotlin 1/2 Simplified Lambda Syntax Extension Functions
  • 9. 9 Building Blocks for DSLs in Kotlin 2/2 Lambdas with Receiver Operator Overloading
  • 10. 10 A Gherkin Test DSL “Gherkin uses a set of special keywords to give structure and meaning to executable specifications.” - Cucumber GIVEN state before behavior is applied WHEN specifies the behavior part THEN defines changes or expected outcome
  • 12. 12 The Calculator: Gherkin-Style Verification “given”-Lambda yields the test subject “when”-Lambda receives test subject and returns test execution result “then”-Lambda receives an assertion object wrapping the test result
  • 13. 13 Gherkin DSL: Capturing the “test setup”
  • 14. 14 Gherkin DSL: Capturing the “execution result”
  • 15. 15 Gherkin DSL: Triggering test and verification
  • 16. 16 Gherkin DSL: Extensibility optional assertion chaining repeated/parallel test execution repeated/clean test subject creation
  • 21. 21 Almost unlimited possibilities ... Some homework for you!
  • 22. 22 Kotlin DSL Building Blocks 1. Capturing declarations/logic using Lambdas 2. Providing Declarative Context using Lambdas with Receiver 3. Providing scoped (extension) functions 4. Improving Readability using infix notation 5. (Operator overloading)
  • 23. 23 What’s the next DSL you’ll be designing? Sprache als Werkzeug DSLs mit Kotlin https://github.com/dxfrontiers/kotlin-gherkin-dsl/tree/kkon https://www.heise.de/developer/artikel/Sprache-als-Werkzeug-DSLs-mit-Kotlin-bauen-4599797.html https://blog.digitalfrontiers.de @maverick_1601 https://github.com/maverick1601 https://bit.ly/2EDAagi Frank Scheffler