What if-your-application-could-speak, by Marcos Silveira
-
Upload
thoughtworks -
Category
Technology
-
view
1.329 -
download
2
description
Transcript of What if-your-application-could-speak, by Marcos Silveira
![Page 1: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/1.jpg)
WHAT IF YOUR APPLICATION COULD SPEAK?
Domain-Specific Language concepts, applications and implementation. An introduction to Language-Driven Development.
Marcos Vinicius@bymarkone
![Page 2: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/2.jpg)
Imagine you have a problem to solve …
![Page 3: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/3.jpg)
SUPPLY CHAIN MANAGEMENT
The complexity of inter company documents exchange
![Page 4: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/4.jpg)
THE NEEDS
Translate Documents
Transfer Documents
![Page 5: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/5.jpg)
Was not satisfactory for this context - too much work!
Altova MapForce - the best solution we found
![Page 6: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/6.jpg)
Document oriented data model
Set of rules that convert an layout to
another
A repository of identified layouts
Several helper functions to help
with the task
An idea
to solve
the problem
![Page 7: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/7.jpg)
Will it work?
After three months - Huge architecture effort spent,
not a single functionality, people lost in system complexity
![Page 8: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/8.jpg)
A language with the semantics of the Document Translation Domain that allowed us to succeed, and to be really faster
We decided to create a…
![Page 9: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/9.jpg)
Domain-Specific
Language
FileTransfer
Banking
Contract Management
Financial
Accounting
Supply Chain
Lexical Analysis
Syntax
Semantics
Grammar
Alphabet
![Page 10: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/10.jpg)
![Page 11: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/11.jpg)
![Page 12: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/12.jpg)
![Page 13: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/13.jpg)
![Page 14: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/14.jpg)
![Page 15: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/15.jpg)
![Page 16: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/16.jpg)
![Page 17: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/17.jpg)
A new era arrived
![Page 18: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/18.jpg)
BUSINESS LEVELHow The Language-Driven Approach Can Change Business
![Page 19: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/19.jpg)
OTHER DSL
!
▫︎A DSL to query Document
▫︎A DSL to program inside Documents
▫︎A DSL to configure Rules for file transfer
▫︎A DSL to configure networks of Documents
▫︎A DSL to configure security and access
![Page 20: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/20.jpg)
META-LANGUAGE
!
▫︎A language that defines a language
▫︎Define name of the objects and verbs of your language
▫︎Define adjective, if they are mandatory, their datatype
▫︎Allows you have feedback of language syntax in parsing
▫︎Validate a language semantically
▫︎ Provide auto-generated APIs documentation
▫︎ Provide information for client IDEs
![Page 21: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/21.jpg)
LANGUAGE TEMPTING
!
▫︎A feature that allows you to simplify the language that the end user can access
!
!
!
!
!
▫︎Granular functionality and modularisation
▫︎On Demand combination to build complex operations
define User “bymarkone" with e-mail “[email protected]“; create Account for “bymarkone”;
activate Account, User “bymarkone”; send confirmation to "bymarkone"
define and activate User "bymarkone"
becomes
![Page 22: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/22.jpg)
BUSINESS SCRIPTING
!
▫︎When we have large amount of tasks
▫︎ E.g. Configuring a new account with N users
▫︎ E.g. Setting up a system
▫︎ E.g. Sending download instructions to several clients
▫︎ Speed in implementation of even complex systems
![Page 23: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/23.jpg)
DEMOING
!
▫︎Build N scenarios for demoing you application
▫︎ End users can understand the language and play with scenarios
![Page 24: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/24.jpg)
ANALYSIS LEVELLanguage Oriented Analysis
![Page 25: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/25.jpg)
add User “Robespierre”; add User “Rosseau”; !“Rosseau” invites “Roberpierre”; “Robespierre" accept invite from “Rosseau" “Rosseau” create group “Vive la France!” with tag “Liberté, égalité, fraternité” “Robespierre" post in “Vive la France!”, message “Let's meet next 14th and kill the king!” !“Roberpierre" list friends; “Rosseau" add message "People who know little are usually great talkers, while men who know much say little”; !“Rosseau" add message “I am sorry to inform you all that our friend and compatriot Roberspierre was guillotined. This bloody revolution is changing out country at a very high price. ”
Let’s do a Social Network System
![Page 26: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/26.jpg)
ARCHITECTURE LEVELLanguage Oriented Architecture
![Page 27: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/27.jpg)
API'S
!
▫︎ REST API - A set of URL’s (names) and Actions
▫︎Must be expressive
▫︎ Limited - beyond crud, has only HTTP verbs
▫︎With a rich language is hard to draw an API that is as rich
▫︎ Expose and API (it can be rest) for language processing
![Page 28: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/28.jpg)
USER EXPERIENCE - UX
!
▫︎ Should be build in top of the language
▫︎We don’t care how modern and visual is the design, as long as it talks the domain language
▫︎ E.g. SQL is a DSL on data query and manipulation - how many UI’s are built in top of that?
▫︎Will an editor with auto-complete and validation work?
![Page 29: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/29.jpg)
TESTING
!
▫︎Unit, integration, component and contract test the application (independent of the language)
▫︎Add tests for language processing - parsing and interpreting
▫︎Add tests for language processing feedback
▫︎Add tests for domain and service executing through DSL
![Page 30: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/30.jpg)
OVERALL ARCHITECTURE
!
▫︎UI Layer
▫︎Web Layer (REST)
▫︎ Language Processing Layer
▫︎Domain/Services Layer
▫︎ Infrastructure Layer
UI Layer
Web / Rest Layer
Language Processing
Domain Layer
Infrastructure Layer
From Martin Fowler’s DSL
![Page 31: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/31.jpg)
PROCESS LEVEL
![Page 32: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/32.jpg)
COMMUNICATION
!
▫︎ The DSL is the language of communication of business
▫︎Devs, QA, BA, PO, Business Specialist, even Stakeholders
▫︎Ubiquitous Language
▫︎ “Semantic Meetings” to understand and refine words of the language, and their meaning
![Page 33: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/33.jpg)
DOMAIN-DRIVEN DESIGN
!
▫︎ Important to start the discussion about Domain meaning - Entities, Services, Aggregates, Value-Objects
▫︎Design and Domain are emergent - they are created/refactored with the development of the application
▫︎Create the DSL
▫︎Create the Semantic Model - connected to the DSL
▫︎ Semantic Model is different than the Domain Model - the first is a subset of the second.
![Page 34: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/34.jpg)
PROGRAMMING LEVELThe fun of building a language
![Page 35: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/35.jpg)
OVERALL OF LANGUAGE PROCESSING
Lexical Analysis Parsing Semantic
AnalysisText Tokens AST
Abstract Syntax
Tree
Code Generation
Semantic Model
![Page 36: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/36.jpg)
grammar IML; !program : (functionDecl | stat | expr)+; functionDecl : type ID LP formalParams? RP block; formalParams : formalParam (COMMA formalParam)*; formalParam : type ID; type : (DOUBLEDECL | INTDECL | STRINGDECL); varDecl : type ID (EQUAL expr)? SEMICOLON ; block : LB stat* RB; assignment : expr EQUAL expr SEMICOLON; conditional : IF expr THEN stat (ELSE stat)?; returnstat : RETURN expr? SEMICOLON; stat : block | varDecl | conditional | returnstat | assignment | expr SEMICOLON ; expr : functionExpr // f() | arrayExpr // g[] | unaryOpExpr | expr binaryOp | idExpr | intExpr | stringExpr
BNF GRAMMARS
![Page 37: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/37.jpg)
ANTLR
![Page 38: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/38.jpg)
LANGUAGE LEVELExpanding horizons of our thought
![Page 39: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/39.jpg)
Grammars
Alphabets
Languages
Syntactics
Semantics
Compilers
State Machines
Regular Languages
Context-Free Grammars
![Page 40: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/40.jpg)
PHILOSOPHICAL LEVELLanguages and Thought
![Page 41: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/41.jpg)
“Because language does not mimic the world, you can do things with it that are impossible under the law of physics. You are a god
in language. You can create. Destroy. Rearrange. Shove words around however you like. You can make up stories about things
that never happened to people who never existed. You can push a camel through the eye of a needle. It’s easy if ‘camel' and ‘needle’
are words.
In language, mortality does not tick relentlessly. You can conceive of yourself as alive forever. Or you can imagine yourself dead. And
then alive again. You can live, die, live, die, live, die, live.”
The First Word: The Search for the Origins of Language
Christine Kenneally
![Page 42: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/42.jpg)
Imaginary
Virtual
Real
![Page 43: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/43.jpg)
![Page 44: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/44.jpg)
![Page 45: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/45.jpg)
![Page 46: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/46.jpg)
Understand the Power of Languages,
Domain-Specific Languages,
for your project, architecture and business
![Page 47: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/47.jpg)
Language-Driven Development
Define a DSL that is going to represent the whole set of functionalities that your application communicates with the external world.
Build this DSL in top of your high-level language, this second will implement the more broad domain logic of your application.
Design your architecture, UX, ubiquitous language, meetings with business, testing, external APIs… in top of that DSL.
This DSL is going to be the language your application speaks
![Page 48: What if-your-application-could-speak, by Marcos Silveira](https://reader033.fdocuments.us/reader033/viewer/2022051610/548db90fb479598e6a8b47b5/html5/thumbnails/48.jpg)
For questions or suggestions: !
Marcos Vinicius @bymarkone
github.com/bymarkone
THANK YOU