• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Domain Specific Languages (EclipseCon 2012)
 

Domain Specific Languages (EclipseCon 2012)

on

  • 553 views

A presentation on domain

A presentation on domain

Statistics

Views

Total Views
553
Views on SlideShare
553
Embed Views
0

Actions

Likes
0
Downloads
10
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Domain Specific Languages (EclipseCon 2012) Domain Specific Languages (EclipseCon 2012) Presentation Transcript

  • DOMAIN-SPECIFIC LANGUAGES @svenefftinge
  • DOMAIN-SPECIFIC LANGUAGEA Domain Specific Language (DSL) is a computer programming language focused on a particular domain.
  • DOMAIN-SPECIFIC LANGUAGE Or just a hip term for a veryreadable and expressiveprogramming interface (aka API)
  • IT IS NOT! A WAY TO LETBUSINESS PEOPLE WRITE SOFTWARE
  • ABSTRACTION "THE ABILITY TO SIMPLIFY MEANS TO ELIMINATE THE UNNECESSARYSO THAT THE NECESSARY MAY SPEAK" (HANS HOFMANN)
  • A TYPICAL WEB APPLICATIONRequestResponse
  • A TYPICAL WEB APPLICATION
  • A TYPICAL WEB APPLICATIONHttp Routing
  • A TYPICAL WEB APPLICATIONHttp Routing Controller
  • A TYPICAL WEB APPLICATIONHttp Routing Controller Domain Model
  • A TYPICAL WEB APPLICATIONHttp Routing Controller Domain Model Data Access
  • A TYPICAL WEB APPLICATIONHttp Routing Controller Domain Model Templates for HTML, CSS and JS Data Access
  • A TYPICAL WEB APPLICATION ?Http Routing ? Controller ? Domain Model ? Templates for HTML, CSS and JS ? Data Access
  • Http Routing
  • HTTP-ROUTING WITH SERVLET API
  • Java / Xtend
  • HTTP-ROUTING WITH JAX-RS Java / Xtend
  • HTTP-ROUTING WITH PLAY!
  • HTTP-ROUTING WITH PLAY! Static Typing ?
  • HTTP-ROUTING WITH PLAY! Static Typing ? Viewpoint Specific Analysis?
  • A TYPICAL WEB APPLICATIONHttp Routing ? Controller ? Domain Model ? Templates for HTML, CSS and JS ? Data Access
  • Controller
  • ControllerUse a General Purpose Language: Java, ..., Xtend, ...
  • A TYPICAL WEB APPLICATIONHttp Routing Controller ? Domain Model ? Templates for HTML, CSS and JS ? Data Access
  • Templates for HTML, CSS and JS
  • <%@ page language="java" import="captchas.CaptchasDotNet" %><html>  <head>    <title>Sample JSP CAPTCHA Query</title>  </head>  <h1>Sample JSP CAPTCHA Query</h1><% CaptchasDotNet captchas = new captchas.CaptchasDotNet(  request.getSession(true),     // Ensure session  "demo",                       // client  "secret"                      // secret  );%>  <form method="get" action="<%=response.encodeUrl("check.jsp")%>">    <table>      <tr>        <td><input name="message" size="60" />        </tr>      <tr>        <td>          <input name="password" size="16" />        </td>      </tr>      <tr>        <td>          <%= captchas.image() %><br>          <a href="<%= captchas.audioUrl() %>">Phonetic spelling (mp3)</a>        </td>      </tr>      <tr>        <td>          <input type="submit" value="Submit" />        </td>      </tr>    </table>  </form></html>
  • <%@ page language="java" import="captchas.CaptchasDotNet" %><html>  <head>  </head> Java Server Pages    <title>Sample JSP CAPTCHA Query</title>  <h1>Sample JSP CAPTCHA Query</h1> Velocity<% CaptchasDotNet captchas = new captchas.CaptchasDotNet(  request.getSession(true),     // Ensure session  "demo",                       // client Freemarker  "secret"                      // secret  );%>  <form method="get" action="<%=response.encodeUrl("check.jsp")%>"> Hamlets    <table>      <tr>        <td><input name="message" size="60" /> Scalate        </tr>      <tr>        <td>          <input name="password" size="16" />        </td>      </tr>      <tr> StringTemplate        <td> Thymeleaf          <%= captchas.image() %><br>          <a href="<%= captchas.audioUrl() %>">Phonetic spelling (mp3)</a> Jamon        </td>      </tr>      <tr> WebMacro        <td>          <input type="submit" value="Submit" />        </td>      </tr>    </table>  </form></html> ...
  • html [ head [ title [$("XML encoding with Xtend")] ] body [ h1 [$("XML encoding with Xtend")] p [$("this format can be used as an alternative to XML")] // an element with attributes and text content a("http://www.xtend-lang.org") [$("Xtend")] // mixed content p [ $("This is some") b[$("mixed")] $("text. For more see the") a("http://www.xtext.org")[$("Xtext")] $("project") ] p [$("some text")] // content generated from arguments p [ for (arg : args) $(arg) ] ]]
  • A TYPICAL WEB APPLICATIONHttp Routing Controller ? Domain Model Templates for HTML, CSS and JS ? Data Access
  • Data Access
  • DATA ACCESS WITHJPA QUERY LANGUAGE
  • .NET LINQ val namesWithFiveCharacters = from name in names                                where name.Length < 5                                 select name;
  • SCALA QUERYval q1 = for(u <- Users if u.first === "Stefan") yield u.id ~ u.last
  • A TYPICAL WEB APPLICATIONHttp Routing Controller ? Domain Model Templates for HTML, CSS and JS Data Access
  • Domain Model
  • @Entitypublic class Customer implements Serializable { private Long id; private String name; private Address address; private Collection<Order> orders = new HashSet<Order>(); private Set<PhoneNumber> phones = new HashSet<PhoneNumber>(); public Customer() {} @Id public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } @OneToMany public Collection<Order> getOrders() { return orders; } public void setOrders(Collection<Order> orders) { this.orders = orders; } @ManyToMany public Set<PhoneNumber> getPhones() { return phones; } public void setPhones(Set<PhoneNumber> phones) { this.phones = phones; }}
  • ABSTRACTION "THE ABILITY TO SIMPLIFY MEANS TO ELIMINATE THE UNNECESSARYSO THAT THE NECESSARY MAY SPEAK" (HANS HOFMANN)
  • @Entitypublic class Customer implements Serializable { private Long id; private String name; private Address address; private Collection<Order> orders = new HashSet<Order>(); private Set<PhoneNumber> phones = new HashSet<PhoneNumber>(); public Customer() {} @Id public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } @OneToMany public Collection<Order> getOrders() { return orders; } public void setOrders(Collection<Order> orders) { this.orders = orders; } @ManyToMany public Set<PhoneNumber> getPhones() { return phones; } public void setPhones(Set<PhoneNumber> phones) { this.phones = phones; }}
  • entity Customer { id Long id String name Address address onetomany Collection<Order> orders manytomany Set<PhoneNumber> phones}
  • com.springsource.roo.pizzashop roo> entity --class ~.domain.Topping --testAutomatically~.domain.Topping roo> field string --fieldName name --notNull --sizeMin 2~.domain.Topping roo> entity --class ~.domain.Base --testAutomatically~.domain.Base roo> field string --fieldName name --notNull --sizeMin 2~.domain.Base roo> entity --class ~.domain.Pizza --testAutomatically~.domain.Pizza roo> field string --fieldName name --notNull --sizeMin 2~.domain.Pizza roo> field number --fieldName price --type java.lang.Float~.domain.Pizza roo> field set --fieldName toppings --type ~.domain.Topping~.domain.Pizza roo> field reference --fieldName base --type ~.domain.Base~.domain.Pizza roo> entity --class ~.domain.PizzaOrder --testAutomatically~.domain.PizzaOrder roo> field string --fieldName name --notNull --sizeMin 2~.domain.PizzaOrder roo> field string --fieldName address --sizeMax 30~.domain.PizzaOrder roo> field number --fieldName total --type java.lang.Float~.domain.PizzaOrder roo> field date --fieldName deliveryDate --type java.util.Date~.domain.PizzaOrder roo> field set --fieldName pizzas --type ~.domain.Pizza
  • LAYERS
  • ABSTRACTION
  • ONE SIZE FITS ALL?
  • Know your toolbox, be creative and have fun! Thank you!