SlideShare uma empresa Scribd logo
1 de 43
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

Mais conteúdo relacionado

Semelhante a 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
 
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
 
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
 
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
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
Sisir Ghosh
 

Semelhante a 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
 

Último

GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
Lokesh Kothari
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
AlMamun560346
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
Sérgio Sacani
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Sérgio Sacani
 

Último (20)

High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)
 
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts ServiceJustdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 22 (Delhi) Call Girl Service
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.Proteomics: types, protein profiling steps etc.
Proteomics: types, protein profiling steps etc.
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
 
Site Acceptance Test .
Site Acceptance Test                    .Site Acceptance Test                    .
Site Acceptance Test .
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 

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

Notas do Editor

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