SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Teaching material for the book
Model-Driven Software Engineering in Practice
by Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Morgan & Claypool, USA, 2012.
Copyright © 2012 Brambilla, Cabot, Wimmer.
www.mdse-book.com
MODEL-TO-TEXT
TRANSFORMATIONS
CHAPTER 9
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Content
§ Introduction
§ Programming Languages based Code Generation
§ M2T Transformation based Code Generation
§ Mastering Code Generation
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
www.mdse-book.com
INTRODUCTION
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Terminology
§  Code generation
§  Wikipedia:
„Code generation is the process by which a compiler‘s code generator
converts a syntactically-correct program into a series of instructions that can
be executed by a machine.“
§  Code Generation in Action (Herrington 2003):
„Code generation is the technique of using or writing programs that write
source code.“
§  Code generation (http://en.wikipedia.org)
§  Compiler Engineering: component of the synthesis phase
§  Software Engineering: program to generate source code
§  Résumé: Term Code Generation is overloaded!
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Code Generation - Basic Questions
§  How much is generated?
§  Which parts can be automatically generated from models?
§  Full or partial code generation?
§  What is generated?
§  Which kind of source code to generate?
§  The less code to generate, the better!
§  How to generate?
§  Which languages and tools to use for developing code generators?
§  GPLs vs. DSLs
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Code Generation in MDA (just an example)
Requirements
Analysis
Design
Implementation
Test&Deployment
CIM
PIM
PSM
Code
Feedback
CIM
PIM
Web
Model
DAO
Model
SQL
Model
JSP
Code
DAO
Code
SQL
Code
Manual
Development
+
Model2Model
Transformation
Model2Model
Transformation
Model2Text
Transformation
Rational Unified Process MDA Artifacts
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
What kind of code is generated?
§  Model-to-Text, whereas text may be distinguished in
§  Program code
§  Documentation
§  Test cases
§  Model serialization (XMI)
§  Direct translation to machine code possible, but inconvenient, error-
prone and hard to optimize
§  Reuse existing code generators
§  Using existing functionality (frameworks, APIs, components)
§  Motto: The less code to generate, the better!
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Example: Platform for Web application development
§  Example: developing a code generator for Web applications
§  What options exist for the to be generated code?
§  Dimensions of Web applications: Content, Hypertext, Presentation
§  Programming languages: Java, C#, Ruby, PHP, …
§  Architectures: 2-layer, 3-layer, MVC, ActiveRecords, …
§  Frameworks: JSF, Spring, Struts, Hibernate, Ruby on Rails, ASP, …
§  Products: MySQL, Tomcat, WebLogic, …
§  Which combinations are appropriate?
§  Experience gained in earlier projects
§  What has proven useful?
§  Reference architectures
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
What kind of code is generated?
Production code Test code
Class
diagrams
State charts
OCL
Object
diagrams
Sequence
diagrams
A B
C
1..*
1
1 *
1
0..1
z1 z2
z3
z4
e e‘
e‘
a:A b:B c:C
m1
m2
m3
b1:B
c1:C
c2:C
b2:B
Picture based on Berhard Rumpe: Agile Modellierung mit UML. Springer, 2012.
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Overview of generation techniques
Model Source Code
Object Code
or
Byte Code
Running
Program
Model
Transformation
Source Code
Generation
Code
Transformation
Byte Code
Rewriting
Reflection
C++
Templates
Java, .
Net
Java,
.Net
AspectJ
ATL
QVT
Code Generation in MDE
Acceleo XPand MofScript
Compilation
Java, .
Net
Based on Markus Völter. A catalog of patterns for program generation. In Proceedings of the 8th
European Conference on Pattern Languages of Programs (EuroPLoP’03), pages 285–320, 2003.
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Why code generation?
§  Code generation enables
§  Separation of application modeling and technical code
§  Increasing maintainability, extensibility, portability to new hardware,
operating systems, and platforms
§  Rapid prototyping
§  Early and fast feedback due to demonstrations and test runs
§  Code generation enables to combine redundant code fragments in
one source
§  Example: DDL, Hibernate, and Java Beans
à may be specified in one UML Class Diagram
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Why code generation? – in contradiction to MDE? (1/2)
§  Often no “real” model simulation possible
§  UML environments mostly do not provide simulation features
§  However, they provide transparent transformation to C, C#, Java, …
§  UML Virtual Machines
§  Interpreter approach – spare code generation for certain platforms
§  Gets a new twist with fUML!
§  Semantics of modeling languages, especially DSMLs, often
defined by code generation
class Car {
public String color;
public int door;
public int engine;
}
Car
Color : String
Door : Integer
Engine : Integer
DSL
Code Generator
Java
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Why code generation? – in contradiction to MDE? (2/2)
§  Runtime environments are designed for programming languages
§  Established frameworks available (Struts, Spring, Hibernate, …)
§  Systems depend on existing software (Web Services, DB)
§  Extensions for code level often required (Logging)
§  Disadvantage: using models and code in parallel
§  No single source of information – OUCH!
§  Having the same information in two places may lead to inconsistences, e.g.,
consider maintainability of systems
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Introduction
Example: MiniUML_2_MiniJava
MiniUML Metamodel
MiniUML Model
class	
  Student	
  extends	
  Person{	
  
	
  
	
  	
  private	
  String	
  regNo;	
  
	
  
	
  	
  public	
  void	
  setRegNo(…){…}	
  
	
  
	
  	
  public	
  String	
  getRegNo(){…}	
  
	
  
}	
  
MiniJava Code
MiniJava Grammar
Model2Text
NamedElement
type : Type
type 0..1
Relationship
0..1
superClass
minCard : Integer
maxCard : Integer
*
*
–  String
–  Boolean
–  …
«enumeration»
Type
ClassDec	
  :=	
  Modifier	
  “class”	
  Identifier	
  [“extends”	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Identifier]	
  ClassBody;	
  
	
  
AttributeDec	
  :=	
  Modifier	
  Type	
  Identifier“;”;	
  
	
  
MethodDec	
  :=	
  Modifier	
  ReturnType	
  Identifier	
  “(”	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ParamList	
  “)”	
  “{”	
  MethodBody	
  “}”;	
  
	
  
Identifier	
  :=	
  {“a”-­‐”z”	
  |	
  “A”-­‐”Z”	
  |	
  “0”-­‐”9”};	
  
Class
Attribute
name: String
Person
Student
regNo : String
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
www.mdse-book.com
PROGRAMMING LANGUAGES
BASED CODE GENERATION
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Introduction – Code generation with Java based on EMF
§  Code generation may be realized using a traditional general purpose
programming language, e.g., Java, C#, …
§  Models are de-serialized to an in-memory object graph
§  Pre-defined XMI de-serialzer provided by meta-modeling frameworks
§  Out-of-the-box support in EMF
§  Model API eases processing of models
§  Generated automatically from metamodels
§  In EMF: .ecore -> .genmodel -> Java code
§  If metamodel not available, you may use reflection
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Model APIs for processing models
§  Example: Ecore-based metamodel and automatically generated
Java code (shown as UML Class Diagram)
Attribute
atts0..*
Class
name : String
name : String
type : Type
Operation
ops0..*
name : String
returnType : Type
Ecore2Java
Attribute
Class
Operation
getName() : String
setName(String) : void
getAtts() : EList<Attribute>
getOps() : EList<Operation>
getName() : String
setName(String) : void
…
getName() : String
setName(String) : void
…
MM in Ecore Model API
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Code generation with Java: phases of code generation
1.  Load models
§  Load XMI file into memory
2.  Process models and produce code
§  Process models by traversing the model structure
§  Use model information to produce code
§  Save code into String variable
3.  Write code
§  Persist String variable to a file using streams
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Code generation with Java: Process and Architecture
Model
Code Generator
XMI Parser FileStream API
Code
String code;
Model API
e.g., UML e.g., JavaJava
Object Graph
M2T
(1) Load (2) Produce (3) Write
Process
Architecture
EMF
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Running Example solved in Java
ResourceSet	
  resourceSet	
  =	
  new	
  ResourceSetImpl();	
  
Resource	
  resource	
  =	
  resourceSet.getResource(URI.create("model.miniUML"));	
  
TreeIterator	
  treeIter	
  =	
  resource.getAllContents();	
  
	
  
while	
  (treeIter.hasNext())	
  {	
  
	
  	
  	
  Object	
  object	
  =	
  treeIt.next();	
  
	
  	
  	
  if	
  (!object	
  instanceof	
  Class)	
  continue;	
  
	
  
	
  	
  	
  Class	
  cl	
  =	
  (Class)	
  object;	
  
	
  	
  	
  String	
  code	
  =	
  "class	
  „	
  +	
  cl.getName()	
  +	
  "{";	
  
	
  	
  	
  //	
  generate	
  Constructor:	
  code	
  +=	
  …	
  
	
  	
  	
  //	
  generate	
  Attributs:	
  code	
  +=	
  …	
  
	
  	
  	
  //	
  generate	
  Methods:	
  code	
  +=	
  …	
  
	
  	
  	
  code	
  +=	
  "}";	
  
	
  	
  	
  	
  
	
  	
  try	
  {	
  
	
  	
  	
  	
  FileOutputStream	
  fos	
  =	
  new	
  FileOutputStream(cl.getName()	
  +".java“);	
  
	
  	
  	
  	
  fos.write(code.getBytes());	
  
	
  	
  	
  	
  fos.close();	
  
	
  	
  }	
  catch	
  (Exception	
  e)	
  {…}	
  
}	
  
Query values via
model API
Create a file for
each class
Get all model
elements
(1) Load
(2) Produce
(3) Write
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Programming languages
Summary
§  Advantages
§  No new languages have to be learned
§  No additional tool dependencies
§  Disadvantages
§  Intermingled static/dynamic code
§  Non-graspable output structure
§  Lack of declarative query language
§  Lack of reusable base functionality
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
www.mdse-book.com
M2T TRANSFORMATION
BASED CODE GENERATION
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
M2T Transformation Languages…
…are Template based
§  Templates are a well-established technique in software
engineering
§  Application domains: Text processing, Web engineering, …
§  Example:
§  Components of a template-based approach
§  Templates
§  Text fragments and embedded meta-markers
§  Meta-markers query an additional data source
§  Have to be interpreted and evaluated in contrast to text fragments
§  Declarative model query: query languages (OCL, XPath, SQL)
§  Imperative model query: programming languages (Java, C#)
§  Template engine
§  Replaces meta-markers with data at runtime and produces output files
Dear Homer Simpson,
Congratulations! You have won …
E-Mail Text
Dear «firstName» «lastName»,
Congratulations! You have won …
Template Text
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
M2T Transformation Languages
Core Architecture
§  Template-based approach at a glance
«context class»
public class «name» { String id, … }
Template
Engine
Query
Result
Input
public class Person { String id, …}
Template
Text fragment
Meta-marker
Output1 Output2
…public class Customer { String id, …}
Person
Customer
…
Source
Model
Produced Text
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
M2T Transformation Languages
Benefits
§  Separated static/dynamic code
§  Templates separate static code, i.e., normal text, from dynamic code that is
described by meta-markers
§  Explicit output structure
§  Primary structure of the template is the output structure
§  Computation logic is embedded in this structure
§  Declarative query language
§  OCL is employed to query the input models
§  Reusable base functionality
§  Support for reading in models, serialize text to files, …
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
M2T Transformation Languages
Approaches
§ A bunch of template languages for M2T transformation
available
§ JET, JET2
§ Xpand, Xtend
§ MOFScript
§ Acceleo
§ XSLT
§ …
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Acceleo
Introduction
§  Acceleo is a mature implementation of the OMG M2T
transformation standard
§  Acceleo website: http://www.eclipse.org/acceleo/
§  M2T Transformation standard: http://www.omg.org/spec/MOFM2T
§  Template-based language
§  Several meta-markers for useful for code generation available
§  Powerful API supporting
§  OCL
§  String manipulation functions
§  …
§  Powerful tooling supporting
§  Editor, debugger, profiler, traceability between model and code, …
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Acceleo
Language Concepts
§ Module concept is provided
§ Imports the metamodels for the input models
§ Act as container for templates
§ A template is always defined for a particular meta-class
§ Plus an optional pre-condition to filter instances
§ Templates may call each other
§ Templates may extended each other
§ Templates contain text and provided meta-markers
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Acceleo
Language Concepts
§  Several meta-markers (called tags) are supported
§  File Tag: To open and close files in which code is generated
§  For/If Tag: Control constructs for defining loops and conditions
§  Query Tag: Reusable helper functions
§  Expression Tag: Compute values that are embedded in the
output
§  Protected Tag: Define areas that are not overridden by future
generation runs
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Acceleo
Example
[module generateJavaClass('http://smvcml/1.0')]
[query public getter(att : Attribute) : String = 'get'+att.name.toUpperFirst() /]
[query public returnStatement(type: String) : String = if type = 'Boolean'
then 'return true;' else '...' endif /]
[template public javaClass(aClass : Class)]
[file (aClass.name.toUpperFirst()+'.java', false, 'UTF-8')]
package entities;
import java.io.Serializable;
public class [aClass.name/] implements Serializable {
[for (att : Attribute | aClass.atts) separator ('n')]
[javaAttribute(att)/]
[/for]
[for (op : Operation | aClass.ops) separator ('n')]
[javaMethod(op)/]
[/for]
}
[/file]
[/template]
…
…
[template public javaAttribute(att : Attribute)]
private [att.type/] [att.name/];
public [att.type/] [att.getter()/]() {
return [att.name/];
}
...
[/template]
[template public javaMethod(op : Operation)]
public [op.type/] [op.name/]() {
// [protected (op.name)]
// Fill in the operation implementation here!
[returnStatement(op.type)/]
// [/protected]
}
[/template]
Import metamodel
(root package)
Template definition
Open output file
Close output file
Expression
Meta class
Loop
Static Text
Protected
Area
Query
Template
Call
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Acceleo
Protected Areas
§  Protected areas are not overriden by the next generator run
§  They are marked by comments
§  Their content is merged with the newly produced code
§  If the right place cannot be found, warning is given!
§  Example
public boolean checkAvailability(){
// Start of user code checkAvailability
// Fill in the operation implementation here!
return true;
// End of user code
}
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
www.mdse-book.com
MASTERING
CODE GENERATION
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Abstracting Templates
§  To ensure that generated code is accepted by developers (cf. Turing
test for code-generation), familiar code should be generated
§  Especially when only a partial code generation is possible!
§  Abstract code generation templates from reference code to have
known structure and coding guidelines considered
§  Acceleo supports dedicated refactorings to transform code into
templates
§  E.g., substitute String with Expression Tag
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Generating step-by-step
§  Divide code generation process into several steps
§  Same applies as for M2M transformations!
§  Transformation chains may use a mixture of M2M and M2T
transformations
§  To keep the gap between the models and the code short
§  If code generators exists, try to produce their required input format with
simpler M2M or M2T transformations
§  E.g., code generator for flat state machines, transform composite state
machines to flat ones and run existing code generator
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Separating transformation logic from text
§  Separete complex transformation logic from text fragements
§  Use queries or libraries that are imported to the M2T transformation
§  By this, templates get more readable and maintainable
§  Queries may be reused
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Mastering code layout
§  Code layout is determined by the template layout
§  Challenging to produce code layout when several control structures
such as loops and conditionals are used in the template
§  Special escape characters for line breaks used for enhancing the reabability
of the template are provided
§  Alternative
§  Use code beautifiers in a post-processing step
§  Supported by Xpand for Java/XML out-of-the-box
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Model/code synchronization issues
§  Protected areas help saving manually added code in succeeding
generator runs
§  Code contained in protected areas is not always automatically
integrated in the newly generated code
§  Assume a method is renamed on model level
§  Where to place the code of the method implementation?
§  Which identifier to use for identifying a protected area?
§  Natural or artificial identifiers?
§  Model refactorings may be replayed on the code level before the next
generator run is started
§  Code in protected areas may also reflect the refactorings!
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Code Generation = M2M + TCS?
§  Code Generation achievable through applying a M2M transformations
to a programming language metamodel
§  If a TCS is available for the programming language metamodel, the
resulting model may be directly serialized into text
§  Only recommended when
§  programming language metamodel + TCS are already available
§  full code generation is possible
Model
Metamodel
(ModLang)
Model
Metamodel
(ProgLang)
M2M Spec
M2M Exec
TCS Spec
(ProgLang)
TCS
Serialization
«conformsTo» «conformsTo» «conformsTo»
visualizes
symbolizes
Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Model-Driven Software Engineering In Practice. Morgan & Claypool 2012.
Teaching material for the book
Model-Driven Software Engineering in Practice
by Marco Brambilla, Jordi Cabot, Manuel Wimmer.
Morgan & Claypool, USA, 2012.
Copyright © 2012 Brambilla, Cabot, Wimmer.
www.mdse-book.com
MODEL-DRIVEN SOFTWARE
ENGINEERING IN PRACTICE
Marco Brambilla,
Jordi Cabot,
Manuel Wimmer.
Morgan & Claypool, USA, 2012.
www.mdse-book.com
www.morganclaypool.com

Weitere ähnliche Inhalte

Was ist angesagt?

5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture
Majong DevJfu
 
Web technologies: Model Driven Engineering
Web technologies: Model Driven EngineeringWeb technologies: Model Driven Engineering
Web technologies: Model Driven Engineering
Piero Fraternali
 
Interpretable Machine Learning
Interpretable Machine LearningInterpretable Machine Learning
Interpretable Machine Learning
inovex GmbH
 
An introduction to the MDA
An introduction to the MDAAn introduction to the MDA
An introduction to the MDA
Lai Ha
 

Was ist angesagt? (20)

5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture5 - Architetture Software - Metamodelling and the Model Driven Architecture
5 - Architetture Software - Metamodelling and the Model Driven Architecture
 
Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code Generation
 
The importance of model fairness and interpretability in AI systems
The importance of model fairness and interpretability in AI systemsThe importance of model fairness and interpretability in AI systems
The importance of model fairness and interpretability in AI systems
 
MDA
MDAMDA
MDA
 
Web technologies: Model Driven Engineering
Web technologies: Model Driven EngineeringWeb technologies: Model Driven Engineering
Web technologies: Model Driven Engineering
 
Bio computing
Bio computingBio computing
Bio computing
 
Interpretable Machine Learning
Interpretable Machine LearningInterpretable Machine Learning
Interpretable Machine Learning
 
An introduction to the MDA
An introduction to the MDAAn introduction to the MDA
An introduction to the MDA
 
DC02. Interpretation of predictions
DC02. Interpretation of predictionsDC02. Interpretation of predictions
DC02. Interpretation of predictions
 
An Introduction to XAI! Towards Trusting Your ML Models!
An Introduction to XAI! Towards Trusting Your ML Models!An Introduction to XAI! Towards Trusting Your ML Models!
An Introduction to XAI! Towards Trusting Your ML Models!
 
The Evolution of AutoML
The Evolution of AutoMLThe Evolution of AutoML
The Evolution of AutoML
 
Generative Adversarial Networks and Their Applications
Generative Adversarial Networks and Their ApplicationsGenerative Adversarial Networks and Their Applications
Generative Adversarial Networks and Their Applications
 
AutoML lectures (ACDL 2019)
AutoML lectures (ACDL 2019)AutoML lectures (ACDL 2019)
AutoML lectures (ACDL 2019)
 
Software development life cycle yazılım geliştirme yaşam döngüsü
Software development life cycle   yazılım geliştirme yaşam döngüsüSoftware development life cycle   yazılım geliştirme yaşam döngüsü
Software development life cycle yazılım geliştirme yaşam döngüsü
 
Understanding Black Box Models with Shapley Values
Understanding Black Box Models with Shapley ValuesUnderstanding Black Box Models with Shapley Values
Understanding Black Box Models with Shapley Values
 
Multichannel User Interfaces
Multichannel User InterfacesMultichannel User Interfaces
Multichannel User Interfaces
 
Class diagram
Class diagramClass diagram
Class diagram
 
Store Item Demand Forecasting - AIT 582
Store Item Demand Forecasting - AIT 582 Store Item Demand Forecasting - AIT 582
Store Item Demand Forecasting - AIT 582
 
Adversarial examples in deep learning (Gregory Chatel)
Adversarial examples in deep learning (Gregory Chatel)Adversarial examples in deep learning (Gregory Chatel)
Adversarial examples in deep learning (Gregory Chatel)
 
ifcpp build guide
ifcpp build guideifcpp build guide
ifcpp build guide
 

Ähnlich wie Model driven software engineering in practice book - Chapter 9 - Model to text transformations and code generation

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
 
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - IntroductionModel-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
Marco Brambilla
 
Model-Driven Software Engineering in Practice - Chapter 10 - Managing models
Model-Driven Software Engineering in Practice - Chapter 10 - Managing modelsModel-Driven Software Engineering in Practice - Chapter 10 - Managing models
Model-Driven Software Engineering in Practice - Chapter 10 - Managing models
Jordi Cabot
 
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
Marco Brambilla
 
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
Jordi Cabot
 
201307 esb01 - iib v9 patterns
201307   esb01 - iib v9 patterns201307   esb01 - iib v9 patterns
201307 esb01 - iib v9 patterns
kondapallishashi
 
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdfacomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
acomprehensivereviewoflargelanguagemodelsfor-230515063139-1fc27b64.pdf
YaserAli40
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
Tuan Ngo
 

Ähnlich wie Model driven software engineering in practice book - Chapter 9 - Model to text transformations and code generation (20)

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
 
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - IntroductionModel-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
 
Model-Driven Software Engineering in Practice - Chapter 10 - Managing models
Model-Driven Software Engineering in Practice - Chapter 10 - Managing modelsModel-Driven Software Engineering in Practice - Chapter 10 - Managing models
Model-Driven Software Engineering in Practice - Chapter 10 - Managing models
 
Model-To-Text Transformation Language chapter 9 – J Cabot model driven engine...
Model-To-Text Transformation Language chapter 9 – J Cabot model driven engine...Model-To-Text Transformation Language chapter 9 – J Cabot model driven engine...
Model-To-Text Transformation Language chapter 9 – J Cabot model driven engine...
 
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
Model-Driven Software Engineering in Practice - Chapter 5 - Integration of Mo...
 
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
Model-Driven Software Engineering in Practice - Chapter 8 - Model-to-model tr...
 
2013 Good Design Is Good Business MDD Embedded Systems
2013 Good Design Is Good Business MDD Embedded Systems2013 Good Design Is Good Business MDD Embedded Systems
2013 Good Design Is Good Business MDD Embedded Systems
 
Future Trends on Software and Systems Modeling
Future Trends on Software and Systems ModelingFuture Trends on Software and Systems Modeling
Future Trends on Software and Systems Modeling
 
Lightweight Model-Driven Engineering
Lightweight Model-Driven EngineeringLightweight Model-Driven Engineering
Lightweight Model-Driven Engineering
 
Sig A&D - MDA
Sig A&D - MDASig A&D - MDA
Sig A&D - MDA
 
Introduction to Mithril JS
Introduction to Mithril JSIntroduction to Mithril JS
Introduction to Mithril JS
 
Cg 2011
Cg 2011Cg 2011
Cg 2011
 
201307 esb01 - iib v9 patterns
201307   esb01 - iib v9 patterns201307   esb01 - iib v9 patterns
201307 esb01 - iib v9 patterns
 
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
 
Final Jspring2009 Mda Slimmer Ontwikkelen Van Java Ee Applicaties
Final Jspring2009 Mda Slimmer Ontwikkelen Van Java Ee ApplicatiesFinal Jspring2009 Mda Slimmer Ontwikkelen Van Java Ee Applicaties
Final Jspring2009 Mda Slimmer Ontwikkelen Van Java Ee Applicaties
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
 
MoDisco Eclipse-OMG Symp 2010
MoDisco Eclipse-OMG Symp 2010MoDisco Eclipse-OMG Symp 2010
MoDisco Eclipse-OMG Symp 2010
 
Acceleo Day - Orange
Acceleo Day - OrangeAcceleo Day - Orange
Acceleo Day - Orange
 
Clean Infrastructure as Code
Clean Infrastructure as CodeClean Infrastructure as Code
Clean Infrastructure as Code
 

Mehr von Marco Brambilla

Hierarchical Transformers for User Semantic Similarity - ICWE 2023
Hierarchical Transformers for User Semantic Similarity - ICWE 2023Hierarchical Transformers for User Semantic Similarity - ICWE 2023
Hierarchical Transformers for User Semantic Similarity - ICWE 2023
Marco Brambilla
 
Exploring the Bi-verse. A trip across the digital and physical ecospheres
Exploring the Bi-verse.A trip across the digital and physical ecospheresExploring the Bi-verse.A trip across the digital and physical ecospheres
Exploring the Bi-verse. A trip across the digital and physical ecospheres
Marco Brambilla
 
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
Marco Brambilla
 
Community analysis using graph representation learning on social networks
Community analysis using graph representation learning on social networksCommunity analysis using graph representation learning on social networks
Community analysis using graph representation learning on social networks
Marco Brambilla
 
Data Cleaning for social media knowledge extraction
Data Cleaning for social media knowledge extractionData Cleaning for social media knowledge extraction
Data Cleaning for social media knowledge extraction
Marco Brambilla
 
Driving Style and Behavior Analysis based on Trip Segmentation over GPS Info...
Driving Style and Behavior Analysis based on Trip Segmentation over GPS  Info...Driving Style and Behavior Analysis based on Trip Segmentation over GPS  Info...
Driving Style and Behavior Analysis based on Trip Segmentation over GPS Info...
Marco Brambilla
 
Myths and challenges in knowledge extraction and analysis from human-generate...
Myths and challenges in knowledge extraction and analysis from human-generate...Myths and challenges in knowledge extraction and analysis from human-generate...
Myths and challenges in knowledge extraction and analysis from human-generate...
Marco Brambilla
 
Web Science. An introduction
Web Science. An introductionWeb Science. An introduction
Web Science. An introduction
Marco Brambilla
 

Mehr von Marco Brambilla (20)

M.Sc. Thesis Topics and Proposals @ Polimi Data Science Lab - 2024 - prof. Br...
M.Sc. Thesis Topics and Proposals @ Polimi Data Science Lab - 2024 - prof. Br...M.Sc. Thesis Topics and Proposals @ Polimi Data Science Lab - 2024 - prof. Br...
M.Sc. Thesis Topics and Proposals @ Polimi Data Science Lab - 2024 - prof. Br...
 
Thesis Topics and Proposals @ Polimi Data Science Lab - 2023 - prof. Brambill...
Thesis Topics and Proposals @ Polimi Data Science Lab - 2023 - prof. Brambill...Thesis Topics and Proposals @ Polimi Data Science Lab - 2023 - prof. Brambill...
Thesis Topics and Proposals @ Polimi Data Science Lab - 2023 - prof. Brambill...
 
Hierarchical Transformers for User Semantic Similarity - ICWE 2023
Hierarchical Transformers for User Semantic Similarity - ICWE 2023Hierarchical Transformers for User Semantic Similarity - ICWE 2023
Hierarchical Transformers for User Semantic Similarity - ICWE 2023
 
Exploring the Bi-verse. A trip across the digital and physical ecospheres
Exploring the Bi-verse.A trip across the digital and physical ecospheresExploring the Bi-verse.A trip across the digital and physical ecospheres
Exploring the Bi-verse. A trip across the digital and physical ecospheres
 
Conversation graphs in Online Social Media
Conversation graphs in Online Social MediaConversation graphs in Online Social Media
Conversation graphs in Online Social Media
 
Trigger.eu: Cocteau game for policy making - introduction and demo
Trigger.eu: Cocteau game for policy making - introduction and demoTrigger.eu: Cocteau game for policy making - introduction and demo
Trigger.eu: Cocteau game for policy making - introduction and demo
 
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
Generation of Realistic Navigation Paths for Web Site Testing using RNNs and ...
 
Analyzing rich club behavior in open source projects
Analyzing rich club behavior in open source projectsAnalyzing rich club behavior in open source projects
Analyzing rich club behavior in open source projects
 
Analysis of On-line Debate on Long-Running Political Phenomena. The Brexit C...
Analysis of On-line Debate on Long-Running Political Phenomena.The Brexit C...Analysis of On-line Debate on Long-Running Political Phenomena.The Brexit C...
Analysis of On-line Debate on Long-Running Political Phenomena. The Brexit C...
 
Community analysis using graph representation learning on social networks
Community analysis using graph representation learning on social networksCommunity analysis using graph representation learning on social networks
Community analysis using graph representation learning on social networks
 
Available Data Science M.Sc. Thesis Proposals
Available Data Science M.Sc. Thesis Proposals Available Data Science M.Sc. Thesis Proposals
Available Data Science M.Sc. Thesis Proposals
 
Data Cleaning for social media knowledge extraction
Data Cleaning for social media knowledge extractionData Cleaning for social media knowledge extraction
Data Cleaning for social media knowledge extraction
 
Iterative knowledge extraction from social networks. The Web Conference 2018
Iterative knowledge extraction from social networks. The Web Conference 2018Iterative knowledge extraction from social networks. The Web Conference 2018
Iterative knowledge extraction from social networks. The Web Conference 2018
 
Driving Style and Behavior Analysis based on Trip Segmentation over GPS Info...
Driving Style and Behavior Analysis based on Trip Segmentation over GPS  Info...Driving Style and Behavior Analysis based on Trip Segmentation over GPS  Info...
Driving Style and Behavior Analysis based on Trip Segmentation over GPS Info...
 
Myths and challenges in knowledge extraction and analysis from human-generate...
Myths and challenges in knowledge extraction and analysis from human-generate...Myths and challenges in knowledge extraction and analysis from human-generate...
Myths and challenges in knowledge extraction and analysis from human-generate...
 
Harvesting Knowledge from Social Networks: Extracting Typed Relationships amo...
Harvesting Knowledge from Social Networks: Extracting Typed Relationships amo...Harvesting Knowledge from Social Networks: Extracting Typed Relationships amo...
Harvesting Knowledge from Social Networks: Extracting Typed Relationships amo...
 
Model-driven Development of User Interfaces for IoT via Domain-specific Comp...
Model-driven Development of  User Interfaces for IoT via Domain-specific Comp...Model-driven Development of  User Interfaces for IoT via Domain-specific Comp...
Model-driven Development of User Interfaces for IoT via Domain-specific Comp...
 
A Model-Based Method for Seamless Web and Mobile Experience. Splash 2016 conf.
A Model-Based Method for  Seamless Web and Mobile Experience. Splash 2016 conf.A Model-Based Method for  Seamless Web and Mobile Experience. Splash 2016 conf.
A Model-Based Method for Seamless Web and Mobile Experience. Splash 2016 conf.
 
Big Data and Stream Data Analysis at Politecnico di Milano
Big Data and Stream Data Analysis at Politecnico di MilanoBig Data and Stream Data Analysis at Politecnico di Milano
Big Data and Stream Data Analysis at Politecnico di Milano
 
Web Science. An introduction
Web Science. An introductionWeb Science. An introduction
Web Science. An introduction
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Model driven software engineering in practice book - Chapter 9 - Model to text transformations and code generation

  • 1. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Teaching material for the book Model-Driven Software Engineering in Practice by Marco Brambilla, Jordi Cabot, Manuel Wimmer. Morgan & Claypool, USA, 2012. Copyright © 2012 Brambilla, Cabot, Wimmer. www.mdse-book.com MODEL-TO-TEXT TRANSFORMATIONS CHAPTER 9
  • 2. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Content § Introduction § Programming Languages based Code Generation § M2T Transformation based Code Generation § Mastering Code Generation
  • 3. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. www.mdse-book.com INTRODUCTION
  • 4. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Terminology §  Code generation §  Wikipedia: „Code generation is the process by which a compiler‘s code generator converts a syntactically-correct program into a series of instructions that can be executed by a machine.“ §  Code Generation in Action (Herrington 2003): „Code generation is the technique of using or writing programs that write source code.“ §  Code generation (http://en.wikipedia.org) §  Compiler Engineering: component of the synthesis phase §  Software Engineering: program to generate source code §  Résumé: Term Code Generation is overloaded!
  • 5. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Code Generation - Basic Questions §  How much is generated? §  Which parts can be automatically generated from models? §  Full or partial code generation? §  What is generated? §  Which kind of source code to generate? §  The less code to generate, the better! §  How to generate? §  Which languages and tools to use for developing code generators? §  GPLs vs. DSLs
  • 6. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Code Generation in MDA (just an example) Requirements Analysis Design Implementation Test&Deployment CIM PIM PSM Code Feedback CIM PIM Web Model DAO Model SQL Model JSP Code DAO Code SQL Code Manual Development + Model2Model Transformation Model2Model Transformation Model2Text Transformation Rational Unified Process MDA Artifacts
  • 7. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction What kind of code is generated? §  Model-to-Text, whereas text may be distinguished in §  Program code §  Documentation §  Test cases §  Model serialization (XMI) §  Direct translation to machine code possible, but inconvenient, error- prone and hard to optimize §  Reuse existing code generators §  Using existing functionality (frameworks, APIs, components) §  Motto: The less code to generate, the better!
  • 8. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Example: Platform for Web application development §  Example: developing a code generator for Web applications §  What options exist for the to be generated code? §  Dimensions of Web applications: Content, Hypertext, Presentation §  Programming languages: Java, C#, Ruby, PHP, … §  Architectures: 2-layer, 3-layer, MVC, ActiveRecords, … §  Frameworks: JSF, Spring, Struts, Hibernate, Ruby on Rails, ASP, … §  Products: MySQL, Tomcat, WebLogic, … §  Which combinations are appropriate? §  Experience gained in earlier projects §  What has proven useful? §  Reference architectures
  • 9. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction What kind of code is generated? Production code Test code Class diagrams State charts OCL Object diagrams Sequence diagrams A B C 1..* 1 1 * 1 0..1 z1 z2 z3 z4 e e‘ e‘ a:A b:B c:C m1 m2 m3 b1:B c1:C c2:C b2:B Picture based on Berhard Rumpe: Agile Modellierung mit UML. Springer, 2012.
  • 10. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Overview of generation techniques Model Source Code Object Code or Byte Code Running Program Model Transformation Source Code Generation Code Transformation Byte Code Rewriting Reflection C++ Templates Java, . Net Java, .Net AspectJ ATL QVT Code Generation in MDE Acceleo XPand MofScript Compilation Java, . Net Based on Markus Völter. A catalog of patterns for program generation. In Proceedings of the 8th European Conference on Pattern Languages of Programs (EuroPLoP’03), pages 285–320, 2003.
  • 11. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Why code generation? §  Code generation enables §  Separation of application modeling and technical code §  Increasing maintainability, extensibility, portability to new hardware, operating systems, and platforms §  Rapid prototyping §  Early and fast feedback due to demonstrations and test runs §  Code generation enables to combine redundant code fragments in one source §  Example: DDL, Hibernate, and Java Beans à may be specified in one UML Class Diagram
  • 12. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Why code generation? – in contradiction to MDE? (1/2) §  Often no “real” model simulation possible §  UML environments mostly do not provide simulation features §  However, they provide transparent transformation to C, C#, Java, … §  UML Virtual Machines §  Interpreter approach – spare code generation for certain platforms §  Gets a new twist with fUML! §  Semantics of modeling languages, especially DSMLs, often defined by code generation class Car { public String color; public int door; public int engine; } Car Color : String Door : Integer Engine : Integer DSL Code Generator Java
  • 13. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Why code generation? – in contradiction to MDE? (2/2) §  Runtime environments are designed for programming languages §  Established frameworks available (Struts, Spring, Hibernate, …) §  Systems depend on existing software (Web Services, DB) §  Extensions for code level often required (Logging) §  Disadvantage: using models and code in parallel §  No single source of information – OUCH! §  Having the same information in two places may lead to inconsistences, e.g., consider maintainability of systems
  • 14. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Introduction Example: MiniUML_2_MiniJava MiniUML Metamodel MiniUML Model class  Student  extends  Person{        private  String  regNo;        public  void  setRegNo(…){…}        public  String  getRegNo(){…}     }   MiniJava Code MiniJava Grammar Model2Text NamedElement type : Type type 0..1 Relationship 0..1 superClass minCard : Integer maxCard : Integer * * –  String –  Boolean –  … «enumeration» Type ClassDec  :=  Modifier  “class”  Identifier  [“extends”                            Identifier]  ClassBody;     AttributeDec  :=  Modifier  Type  Identifier“;”;     MethodDec  :=  Modifier  ReturnType  Identifier  “(”                                ParamList  “)”  “{”  MethodBody  “}”;     Identifier  :=  {“a”-­‐”z”  |  “A”-­‐”Z”  |  “0”-­‐”9”};   Class Attribute name: String Person Student regNo : String
  • 15. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. www.mdse-book.com PROGRAMMING LANGUAGES BASED CODE GENERATION
  • 16. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Introduction – Code generation with Java based on EMF §  Code generation may be realized using a traditional general purpose programming language, e.g., Java, C#, … §  Models are de-serialized to an in-memory object graph §  Pre-defined XMI de-serialzer provided by meta-modeling frameworks §  Out-of-the-box support in EMF §  Model API eases processing of models §  Generated automatically from metamodels §  In EMF: .ecore -> .genmodel -> Java code §  If metamodel not available, you may use reflection
  • 17. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Model APIs for processing models §  Example: Ecore-based metamodel and automatically generated Java code (shown as UML Class Diagram) Attribute atts0..* Class name : String name : String type : Type Operation ops0..* name : String returnType : Type Ecore2Java Attribute Class Operation getName() : String setName(String) : void getAtts() : EList<Attribute> getOps() : EList<Operation> getName() : String setName(String) : void … getName() : String setName(String) : void … MM in Ecore Model API
  • 18. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Code generation with Java: phases of code generation 1.  Load models §  Load XMI file into memory 2.  Process models and produce code §  Process models by traversing the model structure §  Use model information to produce code §  Save code into String variable 3.  Write code §  Persist String variable to a file using streams
  • 19. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Code generation with Java: Process and Architecture Model Code Generator XMI Parser FileStream API Code String code; Model API e.g., UML e.g., JavaJava Object Graph M2T (1) Load (2) Produce (3) Write Process Architecture EMF
  • 20. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Running Example solved in Java ResourceSet  resourceSet  =  new  ResourceSetImpl();   Resource  resource  =  resourceSet.getResource(URI.create("model.miniUML"));   TreeIterator  treeIter  =  resource.getAllContents();     while  (treeIter.hasNext())  {        Object  object  =  treeIt.next();        if  (!object  instanceof  Class)  continue;          Class  cl  =  (Class)  object;        String  code  =  "class  „  +  cl.getName()  +  "{";        //  generate  Constructor:  code  +=  …        //  generate  Attributs:  code  +=  …        //  generate  Methods:  code  +=  …        code  +=  "}";              try  {          FileOutputStream  fos  =  new  FileOutputStream(cl.getName()  +".java“);          fos.write(code.getBytes());          fos.close();      }  catch  (Exception  e)  {…}   }   Query values via model API Create a file for each class Get all model elements (1) Load (2) Produce (3) Write
  • 21. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Programming languages Summary §  Advantages §  No new languages have to be learned §  No additional tool dependencies §  Disadvantages §  Intermingled static/dynamic code §  Non-graspable output structure §  Lack of declarative query language §  Lack of reusable base functionality
  • 22. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. www.mdse-book.com M2T TRANSFORMATION BASED CODE GENERATION
  • 23. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. M2T Transformation Languages… …are Template based §  Templates are a well-established technique in software engineering §  Application domains: Text processing, Web engineering, … §  Example: §  Components of a template-based approach §  Templates §  Text fragments and embedded meta-markers §  Meta-markers query an additional data source §  Have to be interpreted and evaluated in contrast to text fragments §  Declarative model query: query languages (OCL, XPath, SQL) §  Imperative model query: programming languages (Java, C#) §  Template engine §  Replaces meta-markers with data at runtime and produces output files Dear Homer Simpson, Congratulations! You have won … E-Mail Text Dear «firstName» «lastName», Congratulations! You have won … Template Text
  • 24. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. M2T Transformation Languages Core Architecture §  Template-based approach at a glance «context class» public class «name» { String id, … } Template Engine Query Result Input public class Person { String id, …} Template Text fragment Meta-marker Output1 Output2 …public class Customer { String id, …} Person Customer … Source Model Produced Text
  • 25. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. M2T Transformation Languages Benefits §  Separated static/dynamic code §  Templates separate static code, i.e., normal text, from dynamic code that is described by meta-markers §  Explicit output structure §  Primary structure of the template is the output structure §  Computation logic is embedded in this structure §  Declarative query language §  OCL is employed to query the input models §  Reusable base functionality §  Support for reading in models, serialize text to files, …
  • 26. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. M2T Transformation Languages Approaches § A bunch of template languages for M2T transformation available § JET, JET2 § Xpand, Xtend § MOFScript § Acceleo § XSLT § …
  • 27. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Acceleo Introduction §  Acceleo is a mature implementation of the OMG M2T transformation standard §  Acceleo website: http://www.eclipse.org/acceleo/ §  M2T Transformation standard: http://www.omg.org/spec/MOFM2T §  Template-based language §  Several meta-markers for useful for code generation available §  Powerful API supporting §  OCL §  String manipulation functions §  … §  Powerful tooling supporting §  Editor, debugger, profiler, traceability between model and code, …
  • 28. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Acceleo Language Concepts § Module concept is provided § Imports the metamodels for the input models § Act as container for templates § A template is always defined for a particular meta-class § Plus an optional pre-condition to filter instances § Templates may call each other § Templates may extended each other § Templates contain text and provided meta-markers
  • 29. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Acceleo Language Concepts §  Several meta-markers (called tags) are supported §  File Tag: To open and close files in which code is generated §  For/If Tag: Control constructs for defining loops and conditions §  Query Tag: Reusable helper functions §  Expression Tag: Compute values that are embedded in the output §  Protected Tag: Define areas that are not overridden by future generation runs
  • 30. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Acceleo Example [module generateJavaClass('http://smvcml/1.0')] [query public getter(att : Attribute) : String = 'get'+att.name.toUpperFirst() /] [query public returnStatement(type: String) : String = if type = 'Boolean' then 'return true;' else '...' endif /] [template public javaClass(aClass : Class)] [file (aClass.name.toUpperFirst()+'.java', false, 'UTF-8')] package entities; import java.io.Serializable; public class [aClass.name/] implements Serializable { [for (att : Attribute | aClass.atts) separator ('n')] [javaAttribute(att)/] [/for] [for (op : Operation | aClass.ops) separator ('n')] [javaMethod(op)/] [/for] } [/file] [/template] … … [template public javaAttribute(att : Attribute)] private [att.type/] [att.name/]; public [att.type/] [att.getter()/]() { return [att.name/]; } ... [/template] [template public javaMethod(op : Operation)] public [op.type/] [op.name/]() { // [protected (op.name)] // Fill in the operation implementation here! [returnStatement(op.type)/] // [/protected] } [/template] Import metamodel (root package) Template definition Open output file Close output file Expression Meta class Loop Static Text Protected Area Query Template Call
  • 31. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Acceleo Protected Areas §  Protected areas are not overriden by the next generator run §  They are marked by comments §  Their content is merged with the newly produced code §  If the right place cannot be found, warning is given! §  Example public boolean checkAvailability(){ // Start of user code checkAvailability // Fill in the operation implementation here! return true; // End of user code }
  • 32. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. www.mdse-book.com MASTERING CODE GENERATION
  • 33. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Abstracting Templates §  To ensure that generated code is accepted by developers (cf. Turing test for code-generation), familiar code should be generated §  Especially when only a partial code generation is possible! §  Abstract code generation templates from reference code to have known structure and coding guidelines considered §  Acceleo supports dedicated refactorings to transform code into templates §  E.g., substitute String with Expression Tag
  • 34. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Generating step-by-step §  Divide code generation process into several steps §  Same applies as for M2M transformations! §  Transformation chains may use a mixture of M2M and M2T transformations §  To keep the gap between the models and the code short §  If code generators exists, try to produce their required input format with simpler M2M or M2T transformations §  E.g., code generator for flat state machines, transform composite state machines to flat ones and run existing code generator
  • 35. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Separating transformation logic from text §  Separete complex transformation logic from text fragements §  Use queries or libraries that are imported to the M2T transformation §  By this, templates get more readable and maintainable §  Queries may be reused
  • 36. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Mastering code layout §  Code layout is determined by the template layout §  Challenging to produce code layout when several control structures such as loops and conditionals are used in the template §  Special escape characters for line breaks used for enhancing the reabability of the template are provided §  Alternative §  Use code beautifiers in a post-processing step §  Supported by Xpand for Java/XML out-of-the-box
  • 37. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Model/code synchronization issues §  Protected areas help saving manually added code in succeeding generator runs §  Code contained in protected areas is not always automatically integrated in the newly generated code §  Assume a method is renamed on model level §  Where to place the code of the method implementation? §  Which identifier to use for identifying a protected area? §  Natural or artificial identifiers? §  Model refactorings may be replayed on the code level before the next generator run is started §  Code in protected areas may also reflect the refactorings!
  • 38. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Code Generation = M2M + TCS? §  Code Generation achievable through applying a M2M transformations to a programming language metamodel §  If a TCS is available for the programming language metamodel, the resulting model may be directly serialized into text §  Only recommended when §  programming language metamodel + TCS are already available §  full code generation is possible Model Metamodel (ModLang) Model Metamodel (ProgLang) M2M Spec M2M Exec TCS Spec (ProgLang) TCS Serialization «conformsTo» «conformsTo» «conformsTo» visualizes symbolizes
  • 39. Marco Brambilla, Jordi Cabot, Manuel Wimmer. Model-Driven Software Engineering In Practice. Morgan & Claypool 2012. Teaching material for the book Model-Driven Software Engineering in Practice by Marco Brambilla, Jordi Cabot, Manuel Wimmer. Morgan & Claypool, USA, 2012. Copyright © 2012 Brambilla, Cabot, Wimmer. www.mdse-book.com MODEL-DRIVEN SOFTWARE ENGINEERING IN PRACTICE Marco Brambilla, Jordi Cabot, Manuel Wimmer. Morgan & Claypool, USA, 2012. www.mdse-book.com www.morganclaypool.com