Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

23
Copyright © Borland Software Corp., 2008. All rights reserved. | 15 February, 2008. Eclipse Modeling Project as a DSL Toolkit March 19, 2008 Richard C. Gronback Chief ScienEst Borland SoGware CorporaEon Westbrook, CT [email protected]

Transcript of Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Page 1: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Copyright © Borland Software Corp., 2008. All rights reserved. | 15 February, 2008.

EclipseModelingProjectasaDSLToolkit

March19,2008

RichardC.GronbackChiefScienEst

BorlandSoGwareCorporaEonWestbrook,CT

[email protected]

Page 2: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Agenda•  DSLOverview

•  DevelopingaDSL–  AbstractSyntax(domainmodel)

–  GraphicalConcreteSyntax(diagram)

–  TextualConcreteSyntax•  ModelTransformaEon

–  Model‐to‐ModelusingQVTOML

–  Model‐to‐TextusingXpand•  Demo

•  Summary

Page 3: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Domain‐SpecificLanguages

•  DefiniEon–  Alanguagedesignedtobeusefulforaspecificsetoftasks,asopposedtoageneralpurpose

language

•  Syntax–  Abstract:definedusingBNF,EBNF,XSD,MOF,Ecore,etc.–  Concrete:typicallygraphicalortextual

•  Tooling–  Canbelargelygenerated,evenbootstrapped–  Definedusingtheabstractsyntax:

• constraints,validaEon,grammar(textualnotaEon),graphicalnotaEon,model‐to‐modeltransformaEon,model‐to‐textdefiniEon

•  MoEvaEon–  Focusisontheproblemdomain(thepurityofessence)

–  Rigorous,asrequiredbyadheringtotheabstractsyntax•  Downside

–  Model‐centricDSLtoolingrelaEvelyimmature

–  Youmayendupwithsomethingaslarge/complexastheUML

Page 4: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

EclipseModelingProject•  ARangeofModel‐centricDSLCapabiliEes:

–  EclipseModelingFramework(EMF)•  Core,Query,ValidaEon,TransacEon,Teneo,Net4j,CDO

–  GraphicalModelingFramework(GMF)•  GeneraEvetoolingandrunEmefordiagramming

–  TextualModelingFramework(TMF)•  GeneraEveIDEfortextualmodelinglanguages

–  ModelDevelopmentTools(MDT)•  UML2,OCL,UML2Tools,XSD,...

–  Model‐to‐ModelTransformaEon(M2M)•  ATL,QVT(OML)

–  Model‐to‐TextTransformaEon(M2T)•  Xpand,JET

–  GeneraEveModelingTechnologies(GMT)•  Researchandemergingtechnology

–  AmalgamaEon•  Aimstoimprovepackaging,integraEon,andusability

Page 5: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

AbstractSyntaxDevelopment

•  EMFisusedtodeveloptheabstractsyntax–  UsingtheEcoremetamodel(similarbut!=EMOF)–  GeneraEoncapabiliEesusingJET/JMerge

•  Modelcode(API),Editcode,Editor,Tests

–  RunEmeprovidesreflecEon,serializaEon,noEficaEon,etc.–  ApplyconstraintswithMDTOCL

•  WritecustomtemplatestoenforceatrunEme

–  Modelquerysupport•  UsingOCLorSQL‐likequerylanguage

–  ModelvalidaEonframework•  UsingOCLorJava,batchand“live”processing

–  ModeltransacEonsupport

Page 6: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

ObjectConstraintLanguage(OCL)

•  It’sEverywhere(0metolearnit!):–  EMFmodelconstraints,invariants,pre/post‐condiEons,etc.

–  UsedinValidaEonFramework

–  UsedinEMFmodelQuery

–  UsedinGMFforlinkconstraints,iniEalizers,audits,metrics

–  UsedasthebasisofQVTOperaEonalMappingLanguage

–  OCL‐ishlanguagesinMOFScript,Xtend,Xpand

Page 7: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

GraphicalConcreteSyntax

•  GMFisusedtodevelopagraphicalconcretesyntax–  GMFprovidesthetoolingandrunEme;youprovidethenotaEon

•  ConsideraEons:–  IsyourDSLwellsuitedforgraphicalrepresentaEon?–  DoyouneedediEng,orjustvisualizaEon?–  WhereisthebestplacetomapnotaEontodomain?

•  GMFmappingmodel,orusingQVT?(thinkBPMNandBPEL)

–  ReadTuGehlp://www.edwardtuGe.com•  Yes,IknowI’vedisregardedhisadviceregardingPowerPoint:‐(

Page 8: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

GMFOverview

Develop Mapping Model

Adjust Generation Parameters

Create GMF Project

Package and Deploy

Domain Model M T

M M

Tooling Definition Graphical Definition

«x»

Page 9: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

TextualConcreteSyntax

•  TMFwillbeusedtodevelopatextualconcretesyntax•  TextualModelingFramework(TMF)

–  SimilartowhatMarEnFowlercalls“languageworkbenches”–  TargetsEclipseIMP(IDEMetatoolingPlamorm)‐formerly“SAFARI”

•  Abletogeneratehigh‐qualityeditorsforanylanguage•  GrammarcanbeextractedfromanEMFmodel

•  Currently,EmfaEcprovidesatextualsyntaxforEcore•  AvailableonAlphaWorkshlp://www.alphaworks.ibm.com/tech/emfaEc

text

Page 10: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

ModelTransformaEon

•  Twoforms:Model‐to‐ModelandModel‐to‐Text

•  Usedfor:–  IntegraEons–  CodegeneraEon–  ReporEng–  Modelexchange–  ModelmigraEonandrefactoring

•  ConsideraEons:–  TransformaEonlanguagescanbecomplex(OML)

•  ComplexmetamodelsmakeforcomplextransformaEons

–  TransformtodedicatedmodelforcodegeneraEon•  Or,straighttotemplates?(thinkJava,C#,XHTML,etc.)

Page 11: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Model‐to‐ModelTransformaEon

•  QVTcanbeusedforM2MtransformaEons–  ImplementaEonoftheOMG’sQuery/View/TransformaEon–  OperaEonalMappingLanguage(OML)

•  Definesasetofmappingsandqueries–  BasedonextensiontoOCL(+sideeffects)

•  OperatesoninputEMFmodeltoproduceoutputEMFmodel(s)–  Outputcanbethesameasinputforin‐placetransformaEons

–  CoreandRelaEonslanguagesarecoming…•  “Higherlevel”transformaEonlanguages

•  AlternaEvetoQVTisATL–  AnothercomponentwithintheM2Mproject

M M

Page 12: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Model‐to‐TextTransformaEon

•  Xpand:atemplateengineforcodegeneraEon–  Straighmorwardsyntax

«IMPORTmeta::model»«EXTENSIONmy::ExtensionFile»«DEFINEjavaClassFOREnEty»«FILEfileName()»package«javaPackage()»;publicclass«name»{ //implementaEon}«ENDFILE»«ENDDEFINE»

–  Aspect‐OrientedcapabiliEes–  UsedextensivelyinGMF

•  AlternaEveisJET(JSP‐likesyntax)–  BothJETandXpandareintheM2Tproject

M T

Page 13: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

DSLDevelopmentProcess

•  Roles– DomainExpert

•  ProvidesinputonstructureandsemanEcsoftheDSL

– Toolsmith•  Mayalsobethedomainexpert•  DevelopsDSLarEfactsforgeneraEonanddeployment•  AuthorsM2MandM2TtransformaEondefiniEons

– PracEEoner•  The“enduser”

Page 14: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

DSLToolkitOverview:Toolsmith

•  DevelopmentcenteredonEcore‐baseddomainmodel–  DiagramdefiniEonusingGMFforgraphicalconcretesyntax–  Model‐to‐ModeltransformaEonsusingQVTorATL–  Model‐to‐TexttransformaEonsusingXpandorJET–  TextualconcretesyntaxdefinedusingTMF

Domain Model

M T M M

Diagram Definition

Model-to-Model Transformation

Model-to-Text Transformation

text

Textual Syntax Definition

Page 15: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

ToolsmithProcessOverview

Develop M2M Transformation(s)

Develop M2T Transformation(s)

Develop Diagram(s)

Develop Domain Model

Develop Textual Syntax

Generate and Test

Create DSL Project

Package and Deploy

emf

gmf

m2m

m2t

tmf

Page 16: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

DSLToolkitOverview:Toolsmith

•  AnExample:

mindmap.ecore

mindmap.gmfmap

mindmap2requirements.qvto map2csv.xpt

M T M M

mindmap2xhtml.qvto

M M

Class.javajet *

M T

xhtml.ecore

Page 17: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

DSLToolkitOverview:PracEEoner

<html> ...

</html>

sample.mmd

sample.requirements

<html> ...

</html>

M M M T

M T #proj a,b,c,. x,y,z,.

M M

sample.html

sample.mindmap

mindmap2csv

mindmap2xhtml

mindmap2requirements

sample.csv

requirements2html sample.html

Page 18: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Demo

•  Scenario:– ToolsmithtocreateamindmapapplicaEon

•  Graphicalconcretesyntaxonly•  Model‐to‐ModeltransformaEontorequirementsmodel•  Model‐to‐TexttransformaEontoCSVfile

Page 19: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

Summary

•  DevelopingaDomain‐SpecificLanguageisnotatrivialexercise–  But,therearemanypossibleadvantages

–  Requiresadomainexpert[+atoolsmith]

•  Developingcustomtoolingitnotatrivialexercise–  Butit’sfeasible,usingEMPtechnologies–  ReusepotenEalincommonmodelsandtransformaEons

–  Itshouldonlygeteasier

Page 20: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

TheEnd

Thankyou!

[email protected]

QuesEons?

Page 21: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

References•  EclipseModelingProjecthlp://www.eclipse.org/modeling/

•  EclipseModelingFramework(EMF)websitehlp://www.eclipse.org/emf

•  GraphicalModelingFramework(GMF)websitehlp://ww.eclipse.org/gmf

•  Model‐to‐ModelTransformaEon(M2M)websitehlp://ww.eclipse.org/m2m

•  Model‐to‐TextTransformaEon(M2T)websitehlp://ww.eclipse.org/m2t

•  ModelDevelopmentTools(MDT)websitehlp://ww.eclipse.org/mdt

•  EclipseModelingFrameworkTechnology(EMFT)websitehlp://www.eclipse.org/emG

•  EmfaEchlp://www.alphaworks.ibm.com/tech/emfaEc

•  MarEnFowleronLanguageWorkbencheshlp://www.marEnfowler.com/arEcles/

languageWorkbench.html

•  Model‐DrivenSoGwareProductLines(KrzysztofCzarnecki)hlp://swen.uwaterloo.ca/

~chpkim/pp46‐czarnecki.pdf

Page 22: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

SoGwareProductLines

•  LikelythebestapplicaEonofaDSLToolkit–  DSLscanbecustomizedtosuittheneedsofacustomer–  GeneraEonoutput(templates)highlyconfigurable

•  Amature,extensibletargetplamormiskey•  OpEonally,providefullgeneraEon

–  FeaturetreesusedtoselectvariaEons–  Generateonlywhatisrequired

•  AlternaEvely,enableonlywhatisrequired•  ComplementedbyFramework‐SpecificModelingLanguages

(FSMLs)– hlp://gp.uwaterloo.ca/fsmls

Page 23: Eclipse Modeling Project as a DSL Toolkit - EclipseCon Europe 2013 |

Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.

UML™/MDA®vs.DSL/MDD•  UMLisageneralpurposemodelinglanguage

–  Similartogeneralpurposeprogramminglanguages(e.g.Java)

–  CanbeseenasacollecEonofDSLs

–  CanbeusedtodefineaDSL(i.e.usingprofiles)

•  MDA™isatrademarktheOMG–  AcollecEonofstandards

–  ModelsdefinedinMOForUML,refined/constrained/queried(OCL),transformed(QVT),andusedtogeneratetext(MOF2Text),…

–  MDAisoGensynonymouswithModel‐DrivenDevelopment™(MDD)•  andModel‐DrivenEngineering(MDE),andMDSD,and…

•  TheUMLmetamodelcanbethestarEngpointofyourDSMtool–  Howimportantarestandardstoyou?–  Howmuchcomplexitydoyouneedinametamodelorlanguage?