Copyright © Borland Software Corp., 2008. All rights reserved. | 15 February, 2008.
EclipseModelingProjectasaDSLToolkit
March19,2008
RichardC.GronbackChiefScienEst
BorlandSoGwareCorporaEonWestbrook,CT
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
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
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
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
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
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:‐(
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»
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
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.)
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
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
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”
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
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
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
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
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
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
Eclipse Modeling Project as a DSL Toolkit | Long Talk, EclipseCon 2008 | Copyright © Borland Software Corp., 2008. All rights reserved.
TheEnd
Thankyou!
QuesEons?
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
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
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?