SlideShare a Scribd company logo
Model-To-Text Transformation Language chapter 9 – J Cabot
Model-to-Text
Transformations
Mr M.LotfiNia
Email:majidlotfinia12@yahoo.com
1
Model-To-Text Transformation Language chapter 9 – J Cabot
Contents
• Basicsof Model-Driven CodeGeneration
• CodeGeneration Through Programming Languages
• CodeGeneration Through M2T Transformation Languages
 Template-Based Transformation Languages
 Benefitsof M2T Transformation Languages
 Tools
 Acceleo
• Mastering CodeGeneration
2
Model-To-Text Transformation Language chapter 9 – J Cabot
Basic Defination
• Codegeneration hasalong tradition in softwareengineering
• Main goal of MDE: runing system out of themodel
• code-generation in compiler istheprocessof transforming
sourcecodeinto machinecode
• M2T transformation in theareaof MDE
3
Model-To-Text Transformation Language chapter 9 – J Cabot
MDE code-generation
• code-generation istheprocessof transforming modelsinto
sourcecode
• MDE code-generation isbuilt on top of existing compilersfor
programming languages
4
Model-To-Text Transformation Language chapter 9 – J Cabot
Questions
How much is generated?
How to generate?
What is generated?
5
Model-To-Text Transformation Language chapter 9 – J Cabot
How much isgenerated?
• which partsof thecodecan beautomatically generated from
models
• onelayer of theapplication iscompletely generated while
another layer may becompletely manually
developed.
• onelayer isonly partially generated and some
missing partshaveto bemanually completed
full or only a partial ?full or only a partial ?
6
Model-To-Text Transformation Language chapter 9 – J Cabot
Partial code-generation
• using only codegeneration for certain partsof amodel
• other partsarenot touched by thecodegenerator and haveto
beimplemented manually.
7
Model-To-Text Transformation Language chapter 9 – J Cabot
What isgenerated?
• kind of sourcecodeto generate?
• conciseaspossible
• Turing test for codegenerators
• avoiding to reinvent thewheel
• thelesscodeto generatewhich isableto represent asystem,
thebetter.
8
Model-To-Text Transformation Language chapter 9 – J Cabot
How to generate?
• When therequirementsfor thecode-generation arespecified,
namely what hasto beachieved by thecodegenerator
• which partsaregenerated?
• which target languagesareused?
• Ho w to implement theserequirements?
9
Model-To-Text Transformation Language chapter 9 – J Cabot
Code-generation
• Code-generation may bedescribed asthevertical transition
from modelson ahigher-level of abstraction to lower-level
artifacts
• codegeneratorshaveto bridgethisgap in theabstraction
which may beachieved in different
ways.
10
Model-To-Text Transformation Language chapter 9 – J Cabot
implementation of acodegenerator
• Theimplementation of acodegenerator can be
based two approach:
1. MDE principlesapproach
2. Traditional programming approach
11
Model-To-Text Transformation Language chapter 9 – J Cabot
Codegeneration through programming
languages
• A codegenerator may beimplemented asaprogram
• Using themodel API to
 Processtheinput models
 Generateout code
 Print out codestatementsto afile
12
Model-To-Text Transformation Language chapter 9 – J Cabot
Model API
• Model API automatically generated from themetamodel
13
Model-To-Text Transformation Language chapter 9 – J Cabot
Model API
• For each featureof themetaclasses, corresponding getter and
setter methodsaregenerated on theJavaside
• Thismeans, amodel can beread, modified, and completely
created from scratch by using Javacodeinstead of using
modeling editors.
14
Model-To-Text Transformation Language chapter 9 – J Cabot
GPL-based codegenerators
• wepresent how aGPL may beemployed to develop acode
generator
• By thiswedemonstrate:
1) how modelsareprocessed using amodel API generated from
themetamodel
2) highlight thefeaturesneeded to realizeacodegenerator
15
Model-To-Text Transformation Language chapter 9 – J Cabot
Phasesfor codegenerator
1. Load model
 Modelshaveto bedeserialized from their XMI representation
to aobject graph loaded in-memory.
1. Producecode
 Collect themodel information needed for generating thecode
by using themodel API to processthemodels
1. Writecode
 Saved codeto theoutput file
16
Model-To-Text Transformation Language chapter 9 – J Cabot
Phasesfor codegenerator
17
Model-To-Text Transformation Language chapter 9 – J Cabot
Java-based CodeGeneration - Load Model
Model-To-Text Transformation Language chapter 9 – J Cabot
Java-based CodeGeneration - ProduceCode
Model-To-Text Transformation Language chapter 9 – J Cabot
Codegenerator example
20
Model-To-Text Transformation Language chapter 9 – J Cabot
Advantage
• no additional programming skillsareneeded
• It issufficient to know :
 programming languagesused for developing thegenerator and
used astarget
 work with themodel API.
• no additional toolsareneeded for thedesign timenor for the
runtime
21
Model-To-Text Transformation Language chapter 9 – J Cabot
disadvantage
• Intermingled static/dynamic code
 Thereisno separation of static co de and dynamic co de
Static co de: codethat isgenerated in exactly thesameway for
every model element
packagedefinition
Imports
Dynamic code: which isderived from model information
• Missing reusablebasefunctionality
 Codehasto bedeveloped for reading input modelsand
persisting output codeagain and again for each codegenerator
22
Model-To-Text Transformation Language chapter 9 – J Cabot
disadvantage
• Nonegraspableoutput structure
 Thestructureof theoutput isnot easily graspablein thecode
generator specification
 Theproblem isthat theproduced codeisembedded into the
producing code
• Missing declarativequery language
 No declarativequery languagefor accessing model
information isavailable
 thusmany iterators, loops, and conditionsaswell astypecasts
unnecessarily lead to ahugeamount of code.
23
Model-To-Text Transformation Language chapter 9 – J Cabot
Eliminatedisadvantages
• DSLshavebeen developed for generating text from
models.
• Thishasalso lead to an OMG standard called MOFMo delto
Text Transfo rmatio n Language (MOFM2T)
24
Model-To-Text Transformation Language chapter 9 – J Cabot
Codegeneration through M2T TL
• M2T transformation languagesaim at improving the
codegenerator development by tackling theaforestated
drawbacksof GPL-based codegenerators
25
Model-To-Text Transformation Language chapter 9 – J Cabot
TemplateBaseM2T TL
26
Model-To-Text Transformation Language chapter 9 – J Cabot
TemplateBaseM2T TL
• meta-market:
 simpletext fragmentsfor thestatic part
 placeholdersand haveto beinterpreted by atemplate engine
which processesthetemplatesand queriesadditional data
sourcesto producethedynamic parts.
27
Model-To-Text Transformation Language chapter 9 – J Cabot
Benefit M2T Transformation Language
• Separated static/dynamic code
 static text elementsshared by all artifactsaswell asdynamic
partswhich haveto befilled with information specific to each
particular case
• Explicitoutputstructure
28
Model-To-Text Transformation Language chapter 9 – J Cabot
Benefit M2T Transformation Language
• Declarativequery language
 codeisused to accesstheinformation stored in themodels
 current M2T transformation languagesalso allow to useOCL
• Reusablebasefunctionality
 allow to directly read in modelsand to serializetext into files
by just defining configuration files
29
Model-To-Text Transformation Language chapter 9 – J Cabot
Overview of telmplate-baseTL
• Different template-based languagesexist which may be
employed to generatetext from models.
• XSLT:
 XMI serializationsof themodelsmay beprocessed with XSLT
 directly operating on themodel level
30
Model-To-Text Transformation Language chapter 9 – J Cabot
Overview of telmplate-baseTL
• JET:
 JavaEmitter Template
 first approachesfor developing code-generation for EMF-based
models
 JET isnot limited to EMF-based models
 In JET every Java-based object istransformableto text
 JET templatesaretransformed to pureJavacodefor execution
purposes
31
Model-To-Text Transformation Language chapter 9 – J Cabot
Overview of telmplate-baseTL
• Xpand:
 ThisM2T transformation languageemerged in the
openArchitectureWareproject
 migrated to Eclipse
 hosted asan Eclipsemodeling project
 languagefor querying modelswhich isamixtureof Javaand
OCL
32
Model-To-Text Transformation Language chapter 9 – J Cabot
Overview of telmplate-baseTL
• MOFScript:
 providing similar featuressuch asXpand
 OMG standardization effort providing astandardized language
for M2T transformations
 availableasan Eclipseplug-in and supportsEMF-based
models
33
Model-To-Text Transformation Language chapter 9 – J Cabot
Overview of telmplate-baseTL
• Acceleo
 provideapragmatic version of theM2T transformation
standard of theOMG for EMF-based models
 providesfull OCL support for querying models
 maturetool support which hasproven useful in industry
34
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo
• Acceleo isaprotagonist to demonstrateM2T transformation
languages
• practical relevanceand maturetool support
• offersatemplate-based languagefor defining code-generation
templates.
35
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo
• comeswith apowerful API supporting OCL
• advanced functionsfor manipulating strings
• powerful tooling such as:
 editor with syntax highlighting
 error detection
 codecompletion
 refactoring, debugger, profiler
36
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo tag
• Acceleo templatelanguageoffersseveral meta-markerswhich
arecalled tags
• Files
 fileshaveto beopened, filled, and closed
 Thepath and thefilenameareboth defined by an attributeof
thetag
37
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo tag
• Control structures:
 tagsfor defining control structuressuch as:
loops(for tag)
conditional branches(if tag)
• Queries
 OCL queriescan bedefined (query tag)
 used to factor out recurring code
38
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo tag
• Expressions
 generated text to producethedynamic partsof theoutput text
 call other templatesto includethecodegenerated
 Calling other templatescan becompared to method
callsin Java
39
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo tag
• Protected areas
 support projectswhereonly partial code-generation
 partial code-generation supported by protected tag
 Protected areasareused to mark sectionsin thegenerated code
that shall not beoverridden again by subsequent generator
runs.
 Thesesectionstypically contain manually written code
40
Model-To-Text Transformation Language chapter 9 – J Cabot
Acceleo codegeneration example
• Listing 9.2 in thebook, page135
41
Model-To-Text Transformation Language chapter 9 – J Cabot
42
Model-To-Text Transformation Language chapter 9 – J Cabot
43

More Related Content

Similar to Model-To-Text Transformation Language chapter 9 – J Cabot model driven engineering

Model driven software engineering in practice book - Chapter 9 - Model to tex...
Model driven software engineering in practice book - Chapter 9 - Model to tex...Model driven software engineering in practice book - Chapter 9 - Model to tex...
Model driven software engineering in practice book - Chapter 9 - Model to tex...
Marco Brambilla
 
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdfacomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
YaserAli40
 
A Comprehensive Review of Large Language Models for.pptx
A Comprehensive Review of Large Language Models for.pptxA Comprehensive Review of Large Language Models for.pptx
A Comprehensive Review of Large Language Models for.pptx
SaiPragnaKancheti
 
Babel.pptx
Babel.pptxBabel.pptx
Babel.pptx
Parham Abolghasemi
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
Dmytro Mindra
 
Model driven software engineering in practice book - chapter 7 - Developing y...
Model driven software engineering in practice book - chapter 7 - Developing y...Model driven software engineering in practice book - chapter 7 - Developing y...
Model driven software engineering in practice book - chapter 7 - Developing y...
Marco Brambilla
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
Mark Stoodley
 
How to Create Your Own Product-Modeling Environment
How to Create Your Own Product-Modeling EnvironmentHow to Create Your Own Product-Modeling Environment
How to Create Your Own Product-Modeling Environment
Tim Geisler
 
How to Build Your Own Product-Modeling Environment?
How to Build Your Own Product-Modeling Environment?How to Build Your Own Product-Modeling Environment?
How to Build Your Own Product-Modeling Environment?
Tim Geisler
 
Intro To Great Migrations Technology
Intro To Great Migrations TechnologyIntro To Great Migrations Technology
Intro To Great Migrations Technology
Mark Juras
 
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
Tim Geisler
 
Swift programming language
Swift programming languageSwift programming language
Swift programming language
Nijo Job
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
aminmesbahi
 
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worldsmbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
Istvan Rath
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
LenchoMamudeBaro
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLs
deimos
 
Advanced Pattern Authoring with WebSphere Message Broker
Advanced Pattern Authoring with WebSphere Message BrokerAdvanced Pattern Authoring with WebSphere Message Broker
Advanced Pattern Authoring with WebSphere Message Broker
Ant Phillips
 
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use casesModel-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
Jordi Cabot
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Selvaraj Seerangan
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
Sisir Ghosh
 

Similar to Model-To-Text Transformation Language chapter 9 – J Cabot model driven engineering (20)

Model driven software engineering in practice book - Chapter 9 - Model to tex...
Model driven software engineering in practice book - Chapter 9 - Model to tex...Model driven software engineering in practice book - Chapter 9 - Model to tex...
Model driven software engineering in practice book - Chapter 9 - Model to tex...
 
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdfacomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
 
A Comprehensive Review of Large Language Models for.pptx
A Comprehensive Review of Large Language Models for.pptxA Comprehensive Review of Large Language Models for.pptx
A Comprehensive Review of Large Language Models for.pptx
 
Babel.pptx
Babel.pptxBabel.pptx
Babel.pptx
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
Model driven software engineering in practice book - chapter 7 - Developing y...
Model driven software engineering in practice book - chapter 7 - Developing y...Model driven software engineering in practice book - chapter 7 - Developing y...
Model driven software engineering in practice book - chapter 7 - Developing y...
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
 
How to Create Your Own Product-Modeling Environment
How to Create Your Own Product-Modeling EnvironmentHow to Create Your Own Product-Modeling Environment
How to Create Your Own Product-Modeling Environment
 
How to Build Your Own Product-Modeling Environment?
How to Build Your Own Product-Modeling Environment?How to Build Your Own Product-Modeling Environment?
How to Build Your Own Product-Modeling Environment?
 
Intro To Great Migrations Technology
Intro To Great Migrations TechnologyIntro To Great Migrations Technology
Intro To Great Migrations Technology
 
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
Domain-Specific Languages for Product Modeling (CWG 2011 Cologne, SAP Configu...
 
Swift programming language
Swift programming languageSwift programming language
Swift programming language
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worldsmbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
mbeddr meets IncQuer - Combining the Best Features of Two Modeling Worlds
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
Markus Voelter Textual DSLs
Markus Voelter Textual DSLsMarkus Voelter Textual DSLs
Markus Voelter Textual DSLs
 
Advanced Pattern Authoring with WebSphere Message Broker
Advanced Pattern Authoring with WebSphere Message BrokerAdvanced Pattern Authoring with WebSphere Message Broker
Advanced Pattern Authoring with WebSphere Message Broker
 
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use casesModel-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
Model-driven Software Engineering in practice: Chapter 3 - MDSE Use cases
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
 

Recently uploaded

SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
Sérgio Sacani
 
Pests of Storage_Identification_Dr.UPR.pdf
Pests of Storage_Identification_Dr.UPR.pdfPests of Storage_Identification_Dr.UPR.pdf
Pests of Storage_Identification_Dr.UPR.pdf
PirithiRaju
 
Post translation modification by Suyash Garg
Post translation modification by Suyash GargPost translation modification by Suyash Garg
Post translation modification by Suyash Garg
suyashempire
 
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
hozt8xgk
 
Direct Seeded Rice - Climate Smart Agriculture
Direct Seeded Rice - Climate Smart AgricultureDirect Seeded Rice - Climate Smart Agriculture
Direct Seeded Rice - Climate Smart Agriculture
International Food Policy Research Institute- South Asia Office
 
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptxBIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
goluk9330
 
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Sérgio Sacani
 
Male reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptxMale reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptx
suyashempire
 
Introduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptxIntroduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptx
QusayMaghayerh
 
Alternate Wetting and Drying - Climate Smart Agriculture
Alternate Wetting and Drying - Climate Smart AgricultureAlternate Wetting and Drying - Climate Smart Agriculture
Alternate Wetting and Drying - Climate Smart Agriculture
International Food Policy Research Institute- South Asia Office
 
Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8
abhinayakamasamudram
 
Anti-Universe And Emergent Gravity and the Dark Universe
Anti-Universe And Emergent Gravity and the Dark UniverseAnti-Universe And Emergent Gravity and the Dark Universe
Anti-Universe And Emergent Gravity and the Dark Universe
Sérgio Sacani
 
Injection: Risks and challenges - Injection of CO2 into geological rock forma...
Injection: Risks and challenges - Injection of CO2 into geological rock forma...Injection: Risks and challenges - Injection of CO2 into geological rock forma...
Injection: Risks and challenges - Injection of CO2 into geological rock forma...
Oeko-Institut
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
PirithiRaju
 
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdfMending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
Selcen Ozturkcan
 
fermented food science of sauerkraut.pptx
fermented food science of sauerkraut.pptxfermented food science of sauerkraut.pptx
fermented food science of sauerkraut.pptx
ananya23nair
 
The cost of acquiring information by natural selection
The cost of acquiring information by natural selectionThe cost of acquiring information by natural selection
The cost of acquiring information by natural selection
Carl Bergstrom
 
AJAY KUMAR NIET GreNo Guava Project File.pdf
AJAY KUMAR NIET GreNo Guava Project File.pdfAJAY KUMAR NIET GreNo Guava Project File.pdf
AJAY KUMAR NIET GreNo Guava Project File.pdf
AJAY KUMAR
 
cathode ray oscilloscope and its applications
cathode ray oscilloscope and its applicationscathode ray oscilloscope and its applications
cathode ray oscilloscope and its applications
sandertein
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
Scintica Instrumentation
 

Recently uploaded (20)

SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
 
Pests of Storage_Identification_Dr.UPR.pdf
Pests of Storage_Identification_Dr.UPR.pdfPests of Storage_Identification_Dr.UPR.pdf
Pests of Storage_Identification_Dr.UPR.pdf
 
Post translation modification by Suyash Garg
Post translation modification by Suyash GargPost translation modification by Suyash Garg
Post translation modification by Suyash Garg
 
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
 
Direct Seeded Rice - Climate Smart Agriculture
Direct Seeded Rice - Climate Smart AgricultureDirect Seeded Rice - Climate Smart Agriculture
Direct Seeded Rice - Climate Smart Agriculture
 
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptxBIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
 
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
 
Male reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptxMale reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptx
 
Introduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptxIntroduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptx
 
Alternate Wetting and Drying - Climate Smart Agriculture
Alternate Wetting and Drying - Climate Smart AgricultureAlternate Wetting and Drying - Climate Smart Agriculture
Alternate Wetting and Drying - Climate Smart Agriculture
 
Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8Reaching the age of Adolescence- Class 8
Reaching the age of Adolescence- Class 8
 
Anti-Universe And Emergent Gravity and the Dark Universe
Anti-Universe And Emergent Gravity and the Dark UniverseAnti-Universe And Emergent Gravity and the Dark Universe
Anti-Universe And Emergent Gravity and the Dark Universe
 
Injection: Risks and challenges - Injection of CO2 into geological rock forma...
Injection: Risks and challenges - Injection of CO2 into geological rock forma...Injection: Risks and challenges - Injection of CO2 into geological rock forma...
Injection: Risks and challenges - Injection of CO2 into geological rock forma...
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
 
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdfMending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
Mending Clothing to Support Sustainable Fashion_CIMaR 2024.pdf
 
fermented food science of sauerkraut.pptx
fermented food science of sauerkraut.pptxfermented food science of sauerkraut.pptx
fermented food science of sauerkraut.pptx
 
The cost of acquiring information by natural selection
The cost of acquiring information by natural selectionThe cost of acquiring information by natural selection
The cost of acquiring information by natural selection
 
AJAY KUMAR NIET GreNo Guava Project File.pdf
AJAY KUMAR NIET GreNo Guava Project File.pdfAJAY KUMAR NIET GreNo Guava Project File.pdf
AJAY KUMAR NIET GreNo Guava Project File.pdf
 
cathode ray oscilloscope and its applications
cathode ray oscilloscope and its applicationscathode ray oscilloscope and its applications
cathode ray oscilloscope and its applications
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
 

Model-To-Text Transformation Language chapter 9 – J Cabot model driven engineering

  • 1. Model-To-Text Transformation Language chapter 9 – J Cabot Model-to-Text Transformations Mr M.LotfiNia Email:majidlotfinia12@yahoo.com 1
  • 2. Model-To-Text Transformation Language chapter 9 – J Cabot Contents • Basicsof Model-Driven CodeGeneration • CodeGeneration Through Programming Languages • CodeGeneration Through M2T Transformation Languages  Template-Based Transformation Languages  Benefitsof M2T Transformation Languages  Tools  Acceleo • Mastering CodeGeneration 2
  • 3. Model-To-Text Transformation Language chapter 9 – J Cabot Basic Defination • Codegeneration hasalong tradition in softwareengineering • Main goal of MDE: runing system out of themodel • code-generation in compiler istheprocessof transforming sourcecodeinto machinecode • M2T transformation in theareaof MDE 3
  • 4. Model-To-Text Transformation Language chapter 9 – J Cabot MDE code-generation • code-generation istheprocessof transforming modelsinto sourcecode • MDE code-generation isbuilt on top of existing compilersfor programming languages 4
  • 5. Model-To-Text Transformation Language chapter 9 – J Cabot Questions How much is generated? How to generate? What is generated? 5
  • 6. Model-To-Text Transformation Language chapter 9 – J Cabot How much isgenerated? • which partsof thecodecan beautomatically generated from models • onelayer of theapplication iscompletely generated while another layer may becompletely manually developed. • onelayer isonly partially generated and some missing partshaveto bemanually completed full or only a partial ?full or only a partial ? 6
  • 7. Model-To-Text Transformation Language chapter 9 – J Cabot Partial code-generation • using only codegeneration for certain partsof amodel • other partsarenot touched by thecodegenerator and haveto beimplemented manually. 7
  • 8. Model-To-Text Transformation Language chapter 9 – J Cabot What isgenerated? • kind of sourcecodeto generate? • conciseaspossible • Turing test for codegenerators • avoiding to reinvent thewheel • thelesscodeto generatewhich isableto represent asystem, thebetter. 8
  • 9. Model-To-Text Transformation Language chapter 9 – J Cabot How to generate? • When therequirementsfor thecode-generation arespecified, namely what hasto beachieved by thecodegenerator • which partsaregenerated? • which target languagesareused? • Ho w to implement theserequirements? 9
  • 10. Model-To-Text Transformation Language chapter 9 – J Cabot Code-generation • Code-generation may bedescribed asthevertical transition from modelson ahigher-level of abstraction to lower-level artifacts • codegeneratorshaveto bridgethisgap in theabstraction which may beachieved in different ways. 10
  • 11. Model-To-Text Transformation Language chapter 9 – J Cabot implementation of acodegenerator • Theimplementation of acodegenerator can be based two approach: 1. MDE principlesapproach 2. Traditional programming approach 11
  • 12. Model-To-Text Transformation Language chapter 9 – J Cabot Codegeneration through programming languages • A codegenerator may beimplemented asaprogram • Using themodel API to  Processtheinput models  Generateout code  Print out codestatementsto afile 12
  • 13. Model-To-Text Transformation Language chapter 9 – J Cabot Model API • Model API automatically generated from themetamodel 13
  • 14. Model-To-Text Transformation Language chapter 9 – J Cabot Model API • For each featureof themetaclasses, corresponding getter and setter methodsaregenerated on theJavaside • Thismeans, amodel can beread, modified, and completely created from scratch by using Javacodeinstead of using modeling editors. 14
  • 15. Model-To-Text Transformation Language chapter 9 – J Cabot GPL-based codegenerators • wepresent how aGPL may beemployed to develop acode generator • By thiswedemonstrate: 1) how modelsareprocessed using amodel API generated from themetamodel 2) highlight thefeaturesneeded to realizeacodegenerator 15
  • 16. Model-To-Text Transformation Language chapter 9 – J Cabot Phasesfor codegenerator 1. Load model  Modelshaveto bedeserialized from their XMI representation to aobject graph loaded in-memory. 1. Producecode  Collect themodel information needed for generating thecode by using themodel API to processthemodels 1. Writecode  Saved codeto theoutput file 16
  • 17. Model-To-Text Transformation Language chapter 9 – J Cabot Phasesfor codegenerator 17
  • 18. Model-To-Text Transformation Language chapter 9 – J Cabot Java-based CodeGeneration - Load Model
  • 19. Model-To-Text Transformation Language chapter 9 – J Cabot Java-based CodeGeneration - ProduceCode
  • 20. Model-To-Text Transformation Language chapter 9 – J Cabot Codegenerator example 20
  • 21. Model-To-Text Transformation Language chapter 9 – J Cabot Advantage • no additional programming skillsareneeded • It issufficient to know :  programming languagesused for developing thegenerator and used astarget  work with themodel API. • no additional toolsareneeded for thedesign timenor for the runtime 21
  • 22. Model-To-Text Transformation Language chapter 9 – J Cabot disadvantage • Intermingled static/dynamic code  Thereisno separation of static co de and dynamic co de Static co de: codethat isgenerated in exactly thesameway for every model element packagedefinition Imports Dynamic code: which isderived from model information • Missing reusablebasefunctionality  Codehasto bedeveloped for reading input modelsand persisting output codeagain and again for each codegenerator 22
  • 23. Model-To-Text Transformation Language chapter 9 – J Cabot disadvantage • Nonegraspableoutput structure  Thestructureof theoutput isnot easily graspablein thecode generator specification  Theproblem isthat theproduced codeisembedded into the producing code • Missing declarativequery language  No declarativequery languagefor accessing model information isavailable  thusmany iterators, loops, and conditionsaswell astypecasts unnecessarily lead to ahugeamount of code. 23
  • 24. Model-To-Text Transformation Language chapter 9 – J Cabot Eliminatedisadvantages • DSLshavebeen developed for generating text from models. • Thishasalso lead to an OMG standard called MOFMo delto Text Transfo rmatio n Language (MOFM2T) 24
  • 25. Model-To-Text Transformation Language chapter 9 – J Cabot Codegeneration through M2T TL • M2T transformation languagesaim at improving the codegenerator development by tackling theaforestated drawbacksof GPL-based codegenerators 25
  • 26. Model-To-Text Transformation Language chapter 9 – J Cabot TemplateBaseM2T TL 26
  • 27. Model-To-Text Transformation Language chapter 9 – J Cabot TemplateBaseM2T TL • meta-market:  simpletext fragmentsfor thestatic part  placeholdersand haveto beinterpreted by atemplate engine which processesthetemplatesand queriesadditional data sourcesto producethedynamic parts. 27
  • 28. Model-To-Text Transformation Language chapter 9 – J Cabot Benefit M2T Transformation Language • Separated static/dynamic code  static text elementsshared by all artifactsaswell asdynamic partswhich haveto befilled with information specific to each particular case • Explicitoutputstructure 28
  • 29. Model-To-Text Transformation Language chapter 9 – J Cabot Benefit M2T Transformation Language • Declarativequery language  codeisused to accesstheinformation stored in themodels  current M2T transformation languagesalso allow to useOCL • Reusablebasefunctionality  allow to directly read in modelsand to serializetext into files by just defining configuration files 29
  • 30. Model-To-Text Transformation Language chapter 9 – J Cabot Overview of telmplate-baseTL • Different template-based languagesexist which may be employed to generatetext from models. • XSLT:  XMI serializationsof themodelsmay beprocessed with XSLT  directly operating on themodel level 30
  • 31. Model-To-Text Transformation Language chapter 9 – J Cabot Overview of telmplate-baseTL • JET:  JavaEmitter Template  first approachesfor developing code-generation for EMF-based models  JET isnot limited to EMF-based models  In JET every Java-based object istransformableto text  JET templatesaretransformed to pureJavacodefor execution purposes 31
  • 32. Model-To-Text Transformation Language chapter 9 – J Cabot Overview of telmplate-baseTL • Xpand:  ThisM2T transformation languageemerged in the openArchitectureWareproject  migrated to Eclipse  hosted asan Eclipsemodeling project  languagefor querying modelswhich isamixtureof Javaand OCL 32
  • 33. Model-To-Text Transformation Language chapter 9 – J Cabot Overview of telmplate-baseTL • MOFScript:  providing similar featuressuch asXpand  OMG standardization effort providing astandardized language for M2T transformations  availableasan Eclipseplug-in and supportsEMF-based models 33
  • 34. Model-To-Text Transformation Language chapter 9 – J Cabot Overview of telmplate-baseTL • Acceleo  provideapragmatic version of theM2T transformation standard of theOMG for EMF-based models  providesfull OCL support for querying models  maturetool support which hasproven useful in industry 34
  • 35. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo • Acceleo isaprotagonist to demonstrateM2T transformation languages • practical relevanceand maturetool support • offersatemplate-based languagefor defining code-generation templates. 35
  • 36. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo • comeswith apowerful API supporting OCL • advanced functionsfor manipulating strings • powerful tooling such as:  editor with syntax highlighting  error detection  codecompletion  refactoring, debugger, profiler 36
  • 37. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo tag • Acceleo templatelanguageoffersseveral meta-markerswhich arecalled tags • Files  fileshaveto beopened, filled, and closed  Thepath and thefilenameareboth defined by an attributeof thetag 37
  • 38. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo tag • Control structures:  tagsfor defining control structuressuch as: loops(for tag) conditional branches(if tag) • Queries  OCL queriescan bedefined (query tag)  used to factor out recurring code 38
  • 39. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo tag • Expressions  generated text to producethedynamic partsof theoutput text  call other templatesto includethecodegenerated  Calling other templatescan becompared to method callsin Java 39
  • 40. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo tag • Protected areas  support projectswhereonly partial code-generation  partial code-generation supported by protected tag  Protected areasareused to mark sectionsin thegenerated code that shall not beoverridden again by subsequent generator runs.  Thesesectionstypically contain manually written code 40
  • 41. Model-To-Text Transformation Language chapter 9 – J Cabot Acceleo codegeneration example • Listing 9.2 in thebook, page135 41
  • 42. Model-To-Text Transformation Language chapter 9 – J Cabot 42
  • 43. Model-To-Text Transformation Language chapter 9 – J Cabot 43

Editor's Notes

  1. بعنوان سردسته زبانهای انتقال مدل به تکس هست دارای ابزارهای حمایتی و کاربرد عملی زیادی است