When Frameworks Let You Down Platform-Imposed Constraints on the - - PowerPoint PPT Presentation

when frameworks let you down
SMART_READER_LITE
LIVE PREVIEW

When Frameworks Let You Down Platform-Imposed Constraints on the - - PowerPoint PPT Presentation

When Frameworks Let You Down Platform-Imposed Constraints on the Design and Evolution of Domain-Specific Languages Danny M. Groenewegen, Zef Hemel, Lennart C.L. Kats, Eelco Visser When Frameworks Let You Down Platform-Imposed Constraints on


slide-1
SLIDE 1

When Frameworks Let You Down

Platform-Imposed Constraints on the Design and Evolution of Domain-Specific Languages

Danny M. Groenewegen, Zef Hemel, Lennart C.L. Kats, Eelco Visser

slide-2
SLIDE 2

When Frameworks Let You Down

Platform-Imposed Constraints on the Design and Evolution of Domain-Specific Languages

Danny M. Groenewegen, Zef Hemel, Lennart C.L. Kats, Eelco Visser

slide-3
SLIDE 3

Framework DSL

slide-4
SLIDE 4

Framework DSL

slide-5
SLIDE 5

DSL based on Framework

DSL Evolution → DSL Engineering Effort ↑

slide-6
SLIDE 6

When Frameworks Let You Down

Platform-Imposed Constraints on the Design and Evolution of Domain-Specific Languages

Danny M. Groenewegen, Zef Hemel, Lennart C.L. Kats, Eelco Visser

slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9

slide-10
SLIDE 10

DSL based on Framework

DSL Evolution → DSL Engineering Effort ↑

slide-11
SLIDE 11

Data Models

entity Blog { author -> User (inverse=User.blogs) title :: String entries <> Set<BlogEntry> }

slide-12
SLIDE 12

Data Models

entity Blog { author -> User (inverse=User.blogs) title :: String entries <> Set<BlogEntry> } @Entity public class Blog { protected String _title = ""; public String getTitle() { return _title; } public void setTitle(String value) { _title = value; } @ManyToOne protected User _author; public User getAuthor() { return _author; } public void setAuthor(User author) { _title = value; } @OneToMany(mappedBy="_blog", targetEntity=BlogEntry.class) @Cascade(...) protected List<BlogEntry> _entries; public List<BlogEntry> getEntries() { return _entries; } public void setEntries(List<BlogEntry> entries) { _entries = entries; } }

slide-13
SLIDE 13

User Interface

define page editBlogEntry(e : BlogEntry) { form{ table{ row{ "Title: " inputString(e.title) } row{ "Content: " inputWikiText(e.content) } action("Save", save()) } } action save() { e.save(); return blogEntry(e); } }

slide-14
SLIDE 14

User Interface

define page editBlogEntry(e : BlogEntry) { form{ table{ row{ "Title: " inputString(e.title) } row{ "Content: " inputWikiText(e.content) } action("Save", save()) } } action save() { e.save(); return blogEntry(e); } }

<html> ... <body> ... <h:form> <table><tr> <td>Title:</td><td> <h:inputText value="#{editBlogEntry.e.title}"/> </td></tr><tr> <td>Content:</td><td> <h:inputTextarea value="#{editBlogEntry.e.content}"/> </td></tr></table> <h:actionLink action=”#{editBlogEntry.save()}”/> </h:form> ... </body> </html> @Stateful @Name(“editBlogEntry”) public class EditBlogEntry { ... @In @Out private BlogEntry e; public void setE(e) { this.e = e; } public BlogEntry getE() { return this.e; } public void save() { em.persist(e); } ... }

slide-15
SLIDE 15

Evolution

DSL Evolution → DSL Engineering Effort ↑

slide-16
SLIDE 16

Examples

Template Mechanism Access Control Data Model Modularity

slide-17
SLIDE 17

Template Mechanism

define page home() { header{“My Blog”} list { listitem { navigate(home()) { “Home” } } listitem { navigate(about()) { “About” } } } spacer for(p : Post) {

  • utput(p.title)

} spacer “(C) WebDSL, 2008” } define page about() { header{“My Blog”} list { listitem { navigate(home()) { “Home” } } listitem { navigate(about()) { “About” } } } spacer par { “This is about a blog” } spacer “(C) WebDSL, 2008” }

slide-18
SLIDE 18

Template Mechanism

define main() { header{“My Blog”} list { listitem { navigate(home()) { “Home” } } listitem { navigate(about()) { “About” } } } spacer body() spacer “(C) WebDSL, 2008” } define page home() { main() define body() { for(p : Post) {

  • utput(p.title)

} } } define page about() { main() define body() { par { “This is about a blog” } } }

slide-19
SLIDE 19

Template Mechanism

define main() { header{“My Blog”} list { listitem { navigate(home()) { “Home” } } listitem { navigate(about()) { “About” } } } spacer body() spacer “(C) WebDSL, 2008” } define page home() { main() define body() { for(p : Post) {

  • utput(p.title)

} } } define page about() { main() define body() { par { “This is about a blog” } } }

slide-20
SLIDE 20

Template Mechanism

define main() { header{“My Blog”} list { listitem { navigate(home()) { “Home” } } listitem { navigate(about()) { “About” } } } spacer body() spacer “(C) WebDSL, 2008” } define page home() { main() define body() { for(p : Post) {

  • utput(p.title)

} } } define page about() { main() define body() { par { “This is about a blog” } } }

slide-21
SLIDE 21

Template Mechanism

Mismatch with JSF Facelets Template Inheritance Static scope

slide-22
SLIDE 22

Access Control

module userpages define page viewUser(u : User) {

  • utput(u.name)
  • utput(u.authored)

} define page userList() { for (u : User) { navigate(viewUser(u)) { output(u.name) } } }

slide-23
SLIDE 23

Access Control

module userpages define page viewUser(u : User) { init { if(securityContext.principal != u) { goto accessDenied(); } }

  • utput(u.name)
  • utput(u.authored)

} define page userList() { for (u : User) { navigate(viewUser(u)) { output(u.name) } } }

slide-24
SLIDE 24

Access Control

module userpages define page viewUser(u : User) { init { if(securityContext.principal != u) { goto accessDenied(); } }

  • utput(u.name)
  • utput(u.authored)

} define page userList() { for (u : User) { if(securityContext.principal == u) { navigate(viewUser(u)) { output(u.name) } } } }

slide-25
SLIDE 25

Access Control

module ac rule page viewUser(u:User) { principal == u } module userpages define page viewUser(u : User) {

  • utput(u.name)
  • utput(u.authored)

} define page userList() { for (u : User) { navigate(viewUser(u)) { output(u.name) } } }

slide-26
SLIDE 26

Access Control

Mismatch with Seam Access Control Model inflexible built-in policies limited to controller

slide-27
SLIDE 27

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret }

slide-28
SLIDE 28

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret } module paper entity Paper { title :: String authors -> Set<User> abstract :: Text }

slide-29
SLIDE 29

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret authoredPapers -> Set<Paper> } module paper entity Paper { title :: String authors -> Set<User> abstract :: Text }

slide-30
SLIDE 30

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret authoredPapers -> Set<Paper> } module paper entity Paper { title :: String authors -> Set<User> abstract :: Text } module access control rule page viewPaper(p : Paper) { principal in p.viewAccess }

slide-31
SLIDE 31

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret authoredPapers -> Set<Paper> } module paper entity Paper { title :: String authors -> Set<User> abstract :: Text viewAccess -> Set<User> } module access control rule page viewPaper(p : Paper) { principal in p.viewAccess }

slide-32
SLIDE 32

Data Model Modularity

module usermanagement entity User { username :: String password :: Secret } module paper entity Paper { title :: String authors -> Set<User> abstract :: Text } extend entity User { authoredPapers -> Set<Paper> } module access control rule page viewPaper(p : Paper) { principal in p.viewAccess } extend entity Paper { viewAccess -> Set<User> }

slide-33
SLIDE 33

Data Model Modularity

Entity → Java Hibernate class Java does not support partial classes Mismatch with Hibernate and Java

slide-34
SLIDE 34

Scenarios

Model Transformation Adapt the Platform Replace the Platform Just don’t do it

slide-35
SLIDE 35

Just don’t do it

slide-36
SLIDE 36

Just don’t do it

access control limit policy support templates template inheritance data modularity don’t do it

slide-37
SLIDE 37

Just don’t do it

✖ limit DSL potential ✖ possibly expensive application development ✔ inexpensive DSL development ✔ simple DSL development

slide-38
SLIDE 38

Model Transformation

+

slide-39
SLIDE 39

Model Transformation

+ ✖ significantly increases generated code size ✖ can lead to abstraction inversion ✔ independent of framework used ✔ uses same techniques as DSL generator

slide-40
SLIDE 40

Adapt the Platform

slide-41
SLIDE 41

Adapt the Platform

access control extend existing library templates adapt Facelets templates data modularity add partial classes to Java

slide-42
SLIDE 42

Adapt the Platform

✖ keep update in sync with main framework developments ✖ convince framework developers to include changes ✔ DSL synchronized with platform ✔ DSL generation is simple

slide-43
SLIDE 43

Replace the Platform

slide-44
SLIDE 44

Replace the Platform

Plain Java servlets

slide-45
SLIDE 45

Plain Java servlets

Replace the Platform

✖ reinvent the wheel ✖ lost effort ✔ one-to-one mapping ✔ better control of semantics

slide-46
SLIDE 46

Conclusion

DSL Evolution → DSL Engineering Effort ↑

slide-47
SLIDE 47

thin layer on top of framework? independently evolving language?

DSL

slide-48
SLIDE 48

webdsl.org

slide-49
SLIDE 49

WebDSL Evolution

Initial Solutions Access Control Template Mechanism Data Model Modularity Current Solutions Model Transformation Platform Replaced Access Control Template Mechanism Data Model Modularity Model Transformation

}

}