SlideShare une entreprise Scribd logo
1  sur  63
Télécharger pour lire hors ligne
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
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.
Outline



-   Language design strategies
    ★ inductive vs deductive design

-   Compiler architecture
    ★ compilation by normalization

-   WebDSL translation schemes (sketch)
    ★ entities, templates, access control, validation
Design Strategies
Designing a Domain-Specific Language




How does one find domain-specific abstractions?
-   Deductive (top-down) design
-   Inductive (bottom-up) design
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
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
Designing a Domain-Specific Language



From JPA/Seam/JSF to WebDSL
-   JPA to entity declarations
-   JSF to templates
-   Seam actions


See CodeGen 2008 slides
Compiler Architecture
Compiler Architecture

-   Syntax
    ★ check syntactic well-formedness

-   Static semantics
    ★ consistency checking

-   Model-to-model transformation
    ★ desugaring: express constructs in core language
    ★ add higher-level abstractions

-   Code generation
    ★ translate core language models to implementation
Compilation by Normalization
Data Model
object identity
entity declaration




                          one-to-many




                                       inverse relation
 property
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
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
Entity Class

         avoid name clashes




    symbolic identity should be unique
Object Identity
Object Identity




    object identity equals primary key
Value Type Properties




                        avoid name clashes
Many-to-One Properties
                         lazy loading




                            cascading
Inverse Properties




           update other side of relation
HQL Queries
Standard Queries
Standard Queries
Search



-   Lucene / Hibernate Search
    ★ annotations indicate fields to index




-   Search queries
Generating Hibernate Search Annotations
Page Definitions
 & Navigation
GET | POST

         Request       URL

                    Parameters




Client                           Server

                      status


  Page   Response   mime type

                      body
page dispatch




parameter passing
Pages and Templates to Java Classes
Navigate to URL




    navigate(topic(t){output(t.name)}



<a href=”/topic/<%t.id%>”> <%t.name%> </a>



    <a href=”/topic/FooBar”>FooBar</a>
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
TopicPage.serv
TopicPage.serv




request transaction
TopicPage.serv




  handle request
TopicPage.serv




  handle request
TopicPage.initVarsAndArgs
TopicPage.loadArguments
TopicPage.loadArguments
Render Page
Render Page
TopicPage.serv




handle post request
TopicPage.serv




handle post request
class TopicPage extends PageServlet {
  serv(request, response, params) {
    transaction = newTransaction();
    initArguments(params);
    if(isPost()) {
      storeInputs();
      validateInputs();
      handleAction();
    }
    handleExceptions();
    render();
    storeSessionEntities();
    storeMessages();
    transaction.commit();
  }
}
class TopicPage {
  render() {
    s = templateServlet.render();
    response.out(“
      <html>
        <head>
          <%includeCSS()%>
          <%includeJS()%>
          <%title()%>
        </head>
        <body>
          <%s.write()%>
        </body>
      </html>
    “);
  }
}
Templates
Template Lifecycle
                                      for
                                          each
                                                 tem
-   Store inputs                                    plat
                                                        e
    ★ bind request parameters to form inputs

-   Validate inputs
    ★ check validation rules

-   Handle action
    ★ execute selected action

-   Render
    ★ print markup
    ★ render properties of objects
ren
                                      der


                     section nesting




filter special characters
ren
                              der




                     preventing XSS




rendering WikiText
ren
          der




parameter passing
Forms & Data Binding

   form


                                           input

                                                   binding




           submit
                            action


issue: bind request parameters to correct binding expressions
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
Repeated Form Elements




              multiple instances per page
Form Abstraction
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
...
                                                   ren
                                                       d   er
<form onsubmit="return clickFirstButton(this);"
      method="POST" accept-charset="UTF-8"
      action="http://localhost:8080/wiki/editpage2/LoremIpsum"
      id="form51c5e4216d4669e62bee33efc845eb627"
      name="form51c5e4216d4669e62bee33efc845eb627">

  <input type="hidden" value="1"
         name="form51c5e4216d4669e62bee33efc845eb627">
  <input type="hidden" value="LoremIpsum" name="p">
  ...
  <input type="submit" class="button" value="Save"
         name="action61c5e4216d4669e62bee33efc845eb627">
</form>
                                        handle
                                                 action
                 bind action to action code
ren
                                                        der
<p>
  <label for="input241c5e4216d4669e62bee33efc845eb627">
     Text
  </label>
  <textarea id="input241c5e4216d4669e62bee33efc845eb627"
            class="inputTextarea inputWikiText"
            name="input251c5e4216d4669e62bee33efc845eb627">
     value
  </textarea>
</p>
More Template Issues


-   Template calls
    ★ element parameters

-   Nested template definitions
    ★ closures

-   Email templates
    ★ absolute URLs

-   AJAX templates
    ★ accessible directly from client as page
Access Control
access control implemented by model-to-model transformation
page dispatch takes care of loading & storing session entities
More Compilation by Normalization




-   Validation
    ★ validation rules translated to exceptions and
    ★ see paper

-   Workflow
    ★ workflow procedures & processes
    ★ translated to functions, access control, user interface
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

Contenu connexe

Tendances

Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
corneliuskoo
 
Understanding
Understanding Understanding
Understanding
Arun Gupta
 
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
Carles Farré
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
Xavier Noria
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernate
hr1383
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
Prabhdeep Singh
 

Tendances (19)

Expression Language in JSP
Expression Language in JSPExpression Language in JSP
Expression Language in JSP
 
Understanding
Understanding Understanding
Understanding
 
Introduction to Sightly
Introduction to SightlyIntroduction to Sightly
Introduction to Sightly
 
Ridingapachecamel
RidingapachecamelRidingapachecamel
Ridingapachecamel
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
 
Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)
 
C# Advanced L03-XML+LINQ to XML
C# Advanced L03-XML+LINQ to XMLC# Advanced L03-XML+LINQ to XML
C# Advanced L03-XML+LINQ to XML
 
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
[DSBW Spring 2009] Unit 06: Conallen's Web Application Extension for UML (WAE2)
 
Documenting from the Trenches
Documenting from the TrenchesDocumenting from the Trenches
Documenting from the Trenches
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
P1C3 Etiquetas JavaServer Faces al detalle
P1C3 Etiquetas JavaServer Faces al detalleP1C3 Etiquetas JavaServer Faces al detalle
P1C3 Etiquetas JavaServer Faces al detalle
 
Presenter manual php and mysql with cms (specially for summer interns)
Presenter manual php and mysql with cms (specially for summer interns)Presenter manual php and mysql with cms (specially for summer interns)
Presenter manual php and mysql with cms (specially for summer interns)
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernate
 
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
Domain-driven Design in PHP and Symfony - Drupal Camp Wroclaw!
 
Intershop bo
Intershop boIntershop bo
Intershop bo
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
Grails custom tag lib
Grails custom tag libGrails custom tag lib
Grails custom tag lib
 

Similaire à Strategies for Design & Implementation of Domain-Specific Languages

Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
Richie Rump
 

Similaire à Strategies for Design & Implementation of Domain-Specific Languages (20)

Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Training institute in Bangalore
Training institute in BangaloreTraining institute in Bangalore
Training institute in Bangalore
 
Best training institute
Best training institute Best training institute
Best training institute
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding Guideline
 
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
Efficient Rails Test Driven Development (class 3) by Wolfram ArnoldEfficient Rails Test Driven Development (class 3) by Wolfram Arnold
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Swift Micro-services and AWS Technologies
Swift Micro-services and AWS TechnologiesSwift Micro-services and AWS Technologies
Swift Micro-services and AWS Technologies
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte Frühling
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
Introduction to Yesod
Introduction to YesodIntroduction to Yesod
Introduction to Yesod
 
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Entity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic UnicornsEntity Framework: Code First and Magic Unicorns
Entity Framework: Code First and Magic Unicorns
 
Refactoring
RefactoringRefactoring
Refactoring
 

Plus de Eelco Visser

Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
Eelco Visser
 

Plus de Eelco Visser (20)

CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
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
  • 10. Compiler Architecture - Syntax ★ check syntactic well-formedness - Static semantics ★ consistency checking - Model-to-model transformation ★ desugaring: express constructs in core language ★ add higher-level abstractions - Code generation ★ translate core language models to implementation
  • 13. object identity entity declaration one-to-many inverse relation property
  • 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
  • 18. Object Identity object identity equals primary key
  • 19. Value Type Properties avoid name clashes
  • 20. Many-to-One Properties lazy loading cascading
  • 21. Inverse Properties update other side of relation
  • 25. Search - Lucene / Hibernate Search ★ annotations indicate fields to index - Search queries
  • 27. Page Definitions & Navigation
  • 28. GET | POST Request URL Parameters Client Server status Page Response mime type body
  • 30. Pages and Templates to Java Classes
  • 31. Navigate to URL navigate(topic(t){output(t.name)} <a href=”/topic/<%t.id%>”> <%t.name%> </a> <a href=”/topic/FooBar”>FooBar</a>
  • 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
  • 44. class TopicPage extends PageServlet { serv(request, response, params) { transaction = newTransaction(); initArguments(params); if(isPost()) { storeInputs(); validateInputs(); handleAction(); } handleExceptions(); render(); storeSessionEntities(); storeMessages(); transaction.commit(); } }
  • 45. class TopicPage { render() { s = templateServlet.render(); response.out(“ <html> <head> <%includeCSS()%> <%includeJS()%> <%title()%> </head> <body> <%s.write()%> </body> </html> “); } }
  • 47. Template Lifecycle for each tem - Store inputs plat e ★ bind request parameters to form inputs - Validate inputs ★ check validation rules - Handle action ★ execute selected action - Render ★ print markup ★ render properties of objects
  • 48. ren der section nesting filter special characters
  • 49. ren der preventing XSS rendering WikiText
  • 50. ren der parameter passing
  • 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
  • 53. Repeated Form Elements multiple instances per page
  • 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
  • 56. ... ren d er <form onsubmit="return clickFirstButton(this);" method="POST" accept-charset="UTF-8" action="http://localhost:8080/wiki/editpage2/LoremIpsum" id="form51c5e4216d4669e62bee33efc845eb627" name="form51c5e4216d4669e62bee33efc845eb627"> <input type="hidden" value="1" name="form51c5e4216d4669e62bee33efc845eb627"> <input type="hidden" value="LoremIpsum" name="p"> ... <input type="submit" class="button" value="Save" name="action61c5e4216d4669e62bee33efc845eb627"> </form> handle action bind action to action code
  • 57. ren der <p> <label for="input241c5e4216d4669e62bee33efc845eb627"> Text </label> <textarea id="input241c5e4216d4669e62bee33efc845eb627" class="inputTextarea inputWikiText" name="input251c5e4216d4669e62bee33efc845eb627"> value </textarea> </p>
  • 58. More Template Issues - Template calls ★ element parameters - Nested template definitions ★ closures - Email templates ★ absolute URLs - AJAX templates ★ accessible directly from client as page
  • 60. access control implemented by model-to-model transformation
  • 61. page dispatch takes care of loading & storing session entities
  • 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