TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Strategies for Design & Implementation of Domain-Specific Languages
1. Strategies for Design & Implementation
of Domain-Specific Languages
From Java to WebDSL and Back
Lecture 5
Course IN4308
Eelco Visser
Master Computer Science
http://eelcovisser.org Delft University of Technology
2. Warning: the code fragments in this
presentation have been grossly
simplified, even when seemingly bulky.
Consult actual code generated by
WebDSL compiler to get the full story.
3. Outline
- Language design strategies
★ inductive vs deductive design
- Compiler architecture
★ compilation by normalization
- WebDSL translation schemes (sketch)
★ entities, templates, access control, validation
5. Designing a Domain-Specific Language
How does one find domain-specific abstractions?
- Deductive (top-down) design
- Inductive (bottom-up) design
6. Deductive (top-down)
- Analyze problem domain
- Identify elements to specify
★ language constructs
- Identify/design solution domain
★ architecture, technology,
- Investigate implementation
★ code generation templates
- Risk
★ design language that is hard to implement
7. Inductive (bottom-up) design
- Consider best practices in solution domain
- Identify coding patterns
- Identify commonality
★ code generation templates
- Identify variability
★ language constructs
- Risk
★ design language that is too low-level
8. Designing a Domain-Specific Language
From JPA/Seam/JSF to WebDSL
- JPA to entity declarations
- JSF to templates
- Seam actions
See CodeGen 2008 slides
14. Entity Declarations to JPA Entity Classes
- Java Persistence API
- Entity declaration to Java POJO
★ class with private fields, getters, and setters
★ annotations
• values
• relations: one-to-many, many-to-one
★ object identity
- Object-relational mapping
★ entity classes to database tables
★ properties to columns
15. Object Identity
- Automatic identity column for all entities
★ UUID
★ primary key
★ used as foreign key in relations
- Custom symbolic id property
★ key :: String (id)
★ can be changed without compromising foreign keys
★ symbolic id used in URL
16. Entity Class
avoid name clashes
symbolic identity should be unique
32. GET | POST name class
Request URL Dispatch topic
Parameters edittopic
page dispatch table
param value
t Foobar
param map
TopicPage
status
Response mime type
serv
body
51. Forms & Data Binding
form
input
binding
submit
action
issue: bind request parameters to correct binding expressions
52. Data Binding Issues
- Template control-flow
★ template calls: inputs may be nested
★ if-then-else: elements not always present
★ for-loop: multiple occurrences of same form
55. ren
<p>
d er
<label for="input221c5e4216d4669e62bee33efc845eb627">
Title
</label>
<input type="text" value="LoremIpsum" class="inputString"
id="input221c5e4216d4669e62bee33efc845eb627"
name="input231c5e4216d4669e62bee33efc845eb627">
</p>
stor
e inpu
ts
62. More Compilation by Normalization
- Validation
★ validation rules translated to exceptions and
★ see paper
- Workflow
★ workflow procedures & processes
★ translated to functions, access control, user interface
63. Schedule
Lab this week
★ 10 days until deadline Design 1
Cases
★ Case 2: web abstractions
★ See Case 2 for papers to read
Next
★ Lecture 6: language workbenches, modeling
languages
★ Lecture 7: basic code generation