Your SlideShare is downloading. ×
Model-Driven Software Development - Strategies for Design & Implementation of Domain-Specific Languages
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Model-Driven Software Development - Strategies for Design & Implementation of Domain-Specific Languages

1,421

Published on

Lecture 5 of course on Model-Driven Software Development about Strategies for Design & Implementation of Domain-Specific Languages, discussing design and implementation of WebDSL

Lecture 5 of course on Model-Driven Software Development about Strategies for Design & Implementation of Domain-Specific Languages, discussing design and implementation of WebDSL

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,421
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
39
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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 Tuesday, March 16, 2010
  • 2. ARE YOU RECORDING THIS? Tuesday, March 16, 2010
  • 3. 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. Tuesday, March 16, 2010
  • 4. Outline - Language design strategies ★ inductive vs deductive design - Compiler architecture ★ compilation by normalization - WebDSL translation schemes (sketch) ★ entities, templates, access control, validation Tuesday, March 16, 2010
  • 5. Design Strategies Tuesday, March 16, 2010
  • 6. Designing a Domain-Specific Language How does one find domain-specific abstractions? - Deductive (top-down) design - Inductive (bottom-up) design Tuesday, March 16, 2010
  • 7. 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 Tuesday, March 16, 2010
  • 8. 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 Tuesday, March 16, 2010
  • 9. Designing a Domain-Specific Language From JPA/Seam/JSF to WebDSL - JPA to entity declarations - JSF to templates - Seam actions See CodeGen 2008 slides Tuesday, March 16, 2010
  • 10. Compiler Architecture Tuesday, March 16, 2010
  • 11. 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 Tuesday, March 16, 2010
  • 12. Compilation by Normalization Tuesday, March 16, 2010
  • 13. Data Model Tuesday, March 16, 2010
  • 14. object identity entity declaration one-to-many inverse relation property Tuesday, March 16, 2010
  • 15. 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 Tuesday, March 16, 2010
  • 16. 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 Tuesday, March 16, 2010
  • 17. Entity Class avoid name clashes symbolic identity should be unique Tuesday, March 16, 2010
  • 18. Object Identity object identity equals primary key Tuesday, March 16, 2010
  • 19. Value Type Properties avoid name clashes Tuesday, March 16, 2010
  • 20. Many-to-One Properties lazy loading cascading Tuesday, March 16, 2010
  • 21. Inverse Properties update other side of relation Tuesday, March 16, 2010
  • 22. HQL Queries Tuesday, March 16, 2010
  • 23. Standard Queries Tuesday, March 16, 2010
  • 24. Standard Queries Tuesday, March 16, 2010
  • 25. Search - Lucene / Hibernate Search ★ annotations indicate fields to index - Search queries Tuesday, March 16, 2010
  • 26. Generating Hibernate Search Annotations Tuesday, March 16, 2010
  • 27. Page Definitions & Navigation Tuesday, March 16, 2010
  • 28. GET | POST Request URL Parameters Client Server status Page Response mime type body Tuesday, March 16, 2010
  • 29. page dispatch parameter passing Tuesday, March 16, 2010
  • 30. Pages and Templates to Java Classes Tuesday, March 16, 2010
  • 31. Navigate to URL navigate(topic(t){output(t.name)} <a href=”/topic/<%t.id%>”> <%t.name%> </a> <a href=”/topic/FooBar”>FooBar</a> Tuesday, March 16, 2010
  • 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 Tuesday, March 16, 2010
  • 33. TopicPage.serv request transaction Tuesday, March 16, 2010
  • 34. TopicPage.serv handle request Tuesday, March 16, 2010
  • 35. TopicPage.initVarsAndArgs Tuesday, March 16, 2010
  • 36. TopicPage.loadArguments Tuesday, March 16, 2010
  • 37. Render Page Tuesday, March 16, 2010
  • 38. TopicPage.serv handle post request Tuesday, March 16, 2010
  • 39. class TopicPage extends PageServlet { serv(request, response, params) { transaction = newTransaction(); initArguments(params); if(isPost()) { storeInputs(); validateInputs(); handleAction(); } handleExceptions(); render(); storeSessionEntities(); storeMessages(); transaction.commit(); } } Tuesday, March 16, 2010
  • 40. class TopicPage { render() { s = templateServlet.render(); response.out(“ <html> <head> <%includeCSS()%> <%includeJS()%> <%title()%> </head> <body> <%s.write()%> </body> </html> “); } } Tuesday, March 16, 2010
  • 41. Templates Tuesday, March 16, 2010
  • 42. 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 Tuesday, March 16, 2010
  • 43. ren der section nesting filter special characters Tuesday, March 16, 2010
  • 44. ren der preventing XSS rendering WikiText Tuesday, March 16, 2010
  • 45. ren der parameter passing Tuesday, March 16, 2010
  • 46. Forms & Data Binding form input binding submit action issue: bind request parameters to correct binding expressions Tuesday, March 16, 2010
  • 47. 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 Tuesday, March 16, 2010
  • 48. Repeated Form Elements multiple instances per page Tuesday, March 16, 2010
  • 49. Form Abstraction Tuesday, March 16, 2010
  • 50. 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 Tuesday, March 16, 2010
  • 51. ... 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 Tuesday, March 16, 2010
  • 52. ren der <p> <label for="input241c5e4216d4669e62bee33efc845eb627"> Text </label> <textarea id="input241c5e4216d4669e62bee33efc845eb627" class="inputTextarea inputWikiText" name="input251c5e4216d4669e62bee33efc845eb627"> value </textarea> </p> Tuesday, March 16, 2010
  • 53. More Template Issues - Template calls ★ element parameters - Nested template definitions ★ closures - Email templates ★ absolute URLs - AJAX templates ★ accessible directly from client as page Tuesday, March 16, 2010
  • 54. Access Control Tuesday, March 16, 2010
  • 55. access control implemented by model-to-model transformation Tuesday, March 16, 2010
  • 56. page dispatch takes care of loading & storing session entities Tuesday, March 16, 2010
  • 57. More Compilation by Normalization - Validation ★ validation rules translated to exceptions and ★ see paper - Workflow ★ workflow procedures & processes ★ translated to functions, access control, user interface Tuesday, March 16, 2010
  • 58. 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 Tuesday, March 16, 2010

×