model-driven-software-engineering-in-practice-second-edition-synthesis-lectures-on-software-engineering-2nbsped-1627057080-9781627057080
model-driven-software-engineering-in-practice-second-edition-synthesis-lectures-on-software-engineering-2nbsped-1627057080-9781627057080
Editor
Luciano Baresi, Politecnico di Milano
The Synthesis Lectures on Software Engineering series publishes short books
(75-125 pages) on conceiving, specifying, architecting, designing, implementing,
managing, measuring, analyzing, validating, and verifying complex software
systems. The goal is to provide both focused monographs on the different phases
of the software process and detailed presentations of frontier topics. Premier
software engineering conferences, such as ICSE, ESEC/FSE, and ASE will help
shape the purview of the series and make it evolve.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means—electronic, mechanical, photocopy, recording, or any other
except for brief quotations in printed reviews, without the prior permission of the publisher.
DOI 10.2200/S00751ED2V01Y201701SWE004
Lecture #4
Series Editor: Luciano Baresi, Politecnico di Milano
Series ISSN
Print 2328-3319 Electronic 2328-3327
Model-Driven
Software Engineering in Practice
Second Edition
Marco Brambilla
Politecnico di Milano, Italy
Jordi Cabot
ICREA and Open University of Catalonia (UOC), Spain
Manuel Wimmer
TU Wien, Austria
KEYWORDS
modeling, software engineering, UML, domain-specific language, model-
driven engineering, code generation, reverse engineering, model
transformation, MDD, MDA, MDE, MDSE, OMG, DSL, EMF, Eclipse
Contents
Foreword
Acknowledgments
1 Introduction
1.1 Purpose and Use of Models
1.2 Modeling for Software Development
1.3 How to Read this Book
2 MDSE Principles
2.1 MDSE Basics
2.2 Lost in Acronyms: The MD* Jungle
2.3 Overview of the MDSE Methodology
2.3.1 Overall Vision
2.3.2 Domains, Platforms, and Technical Spaces
2.3.3 Modeling Languages
2.3.4 Metamodeling
2.3.5 Transformations
2.4 Tool Support
2.4.1 Drawing Tools vs. Modeling Tools
2.4.2 Model-based vs. Programming-based MDSE Tools
2.4.3 Eclipse and EMF
2.5 Adoption and Criticisms of MDSE
8 Model-to-Model Transformations
8.1 Model Transformations and their Classification
8.2 Exogenous, Out-place Transformations
8.3 Endogenous, In-place Transformations
8.4 Mastering Model Transformations
8.4.1 Divide and Conquer: Model Transformation Chains
8.4.2 HOT: Everything is a Model, Even Transformations!
8.4.3 Beyond Batch: Incremental and Lazy Transformations
8.4.4 Bi-directional Model Transformations
9 Model-to-Text Transformations
9.1 Basics of Model-driven Code Generation
9.2 Code Generation Through Programming Languages
9.3 Code Generation Through M2T Transformation Languages
9.3.1 Benefits of M2T Transformation Languages
9.3.2 Template-based Transformation Languages: An Overview
9.3.3 Acceleo: An Implementation of the M2T Transformation
Standard
9.4 Mastering Code Generation
9.5 Excursus: Code Generation through M2M Transformations and
TCS
10 Managing Models
10.1 Model Interchange
10.2 Model Persistence
10.3 Model Comparison
10.4 Model Versioning
10.5 Model Co-evolution
10.6 Global Model Management
10.7 Model Quality
10.7.1 Verifying Models
10.7.2 Testing and Validating Models
10.7.3 Reviewing Models
10.8 Collaborative Modeling
11 Summary
Bibliography
Authors’ Biographies
Index
Foreword
This book wouldn’t be the same without all the enriching discussions we have
had with many other MDSE fans (and detractors!) during the last years—in
person or within online forums. It would be almost impossible to list all of them
here and therefore we wish to thank them all and to acknowledge their direct or
indirect contribution to this book and to the MDE field at large, especially our
current and previous colleagues.
An explicit mention must go to the ones who concretely helped us in the
writing of this book. First of all, thanks to Diane Cerra, our Managing Editor at
Morgan & Claypool, who believed in our project since the beginning and
followed us with infinite patience throughout the whole book production
process.
Secondly, thanks to Richard Soley, Chairman and CEO of OMG, who
graciously agreed to introduce our work with his authoritative foreword.
And finally, last but not least, thanks to all the people that helped review the
book: Ed Seidewitz (Model Driven Solutions), Davide di Ruscio (L’Aquila
University), Juan Carlos Molina (Integranova), Vicente Pelechano (Polytechnic
University of Valencia), and a bunch of our own colleagues and friends who
carefully read and commented on what we were writing.
Introduction
MDSE Curious
If you are interested in general in MDSE practices and you would like to learn
more about them, without necessarily expecting to do the technical work of
using model-driven approaches or developing modeling languages, you are
probably MDSE curious.
This attitude is extremely useful for CTOs, CIOs, enterprise architects,
business and team managers who want to have a bird’s eye view on the matter,
so as to make the appropriate decisions when it comes to choosing the best
development techniques for their company or team.
In this case, our suggestion is to focus on the first part of the book, namely
the: MDSE principles (Chapter 2) and usage (Chapter 3); MDA proposal by
OMG (Chapter 4); and overview on the modeling languages (Chapter 6). We
also suggest reading how to integrate MDSE in existing development processes
(Chapter 5) and possibly the tools that support the management of MDSE
artifacts (Chapter 10).
MDSE User
If you are a technical person (e.g., software analyst, developer, or designer) and
you expect to use in your development activities some MDSE approach or
modeling notation, with the purpose of improving your productivity and learning
a more conceptual way for dealing with the software development problem, you
are propably an MDSE user. In this case, you are most likely not going to
develop new modeling languages or methods, but you will aim at using the
existing ones at your best.
If you think you fall into this category, we recommend that you read at least
the basics on MDSE principles and usage in Chapters 2 and 3; overview on
OMG’s MDA approach (Chapter 4) and on modeling languages (Chapter 6);
description of Model-to-Model and Model-to-Text transformations (Chapters 8
and 9, respectively); and tools that support the management of MDSE projects
(Chapter 10).
MDSE Developer
Finally, if you already have some basic knowledge of MDSE but you want to
move forward and become a hardcore MDSE adopter, by delving into the
problems related to defining new DSLs, applying end-to-end MDSE practices in
your software factory, and so on, then we classify your profile as MDSE
developer.
As such, you are probably interested mostly in the second part of the book,
which describes all the details on how to technically apply MDSE. Therefore, we
recommend that you read at least the following chapters: the overview on
modeling languages (Chapter 6), the basis on domain-specific modeling
languages (Chapter 7); the description of Model-to-Model and Model-to-Text
transformations (Chapters 8 and 9, respectively), and the tools that support the
management of MDSE artifacts (Chapter 10).
Optionally, if you need to refresh your mind on the basic MDSE principles,
you can read Chapters 2 and 3. As a final read, if you are also involved in
management activities, you can read the chapter on agile development processes
(Chapter 5).
Student
If you are a student of an academic or professional course, our suggestion is to
go through the whole book so as to get at least the flavor of the objectives and
implications of the MDSE approach. In this case, this book possibly will not be
enough to cover in detail all the topics of the course you are following.
Throughout the text we offer a good set of references to books, articles, and
online resources that will help you investigate the topics you need to study in
detail.
Instructor
If you are an instructor of an academic or professional course, you will be able
to target your specific teaching needs by selecting some chapters of the book
depending on the time span available in your course and the level of technical
depth you want to provide your students with. The teaching materials covering
the whole book are available as slidesets, linked from the book web site
(http://www.mdse-book.com).
In addition to the contents of the book, more resources are provided on the
book’s website (http://www.mdse-book.com), including the examples presented
in the book.
1http://martinfowler.com/bliki/UmlMode.html
CHAPTER 2
MDSE Principles
Models are paramount for understanding and sharing knowledge about complex
software. MDSE is conceived as a tool for making this assumption a concrete
way of working and thinking, by transforming models into first-class citizens in
software engineering. Obviously, the purpose of models can span from
communication between people to executability of the designed software: the
way in which models are defined and managed will be based on the actual needs
that they will address. Due to the various possible needs that MDSE addresses,
its role becomes that of defining sound engineering approaches to the definition
of models, transformations, and their combinations within a software
development process.
This chapter introduces the basic concepts of MDSE and discusses its
adoption and perspectives.
2.3.4 METAMODELING
As models play a pervasive role in MDSE, a natural subsequent step to the
definition of models is to represent the models themselves as “instances” of
some more abstract models. Hence, exactly in the same way we define a model
as an abstraction of phenomena in the real world, we can define a metamodel as
yet another abstraction, highlighting properties of the model itself. In a practical
sense, metamodels basically constitute the definition of a modeling language,
since they provide a way of describing the whole class of models that can be
represented by that language.
Therefore, one can define models of the reality, and then models that
describe models (called metamodels) and recursively models that describe
metamodels (called meta-metamodels). While in theory one could define infinite
levels of metamodeling, it has been shown, in practice, that meta-metamodels
can be defined based on themselves, and therefore it usually does not make sense
to go beyond this level of abstraction. At any level where we consider the
metamodeling practice, we say that a model conforms to its metamodel in the
way that a computer program conforms to the grammar of the programming
language in which it is written. More specifically, we say that a model conforms
to its metamodel when all its elements can be expressed as instances of the
corresponding metamodel (meta)classes as seen in Figure 2.4.
2.3.5 TRANSFORMATIONS
Besides models, model transformations represent the other crucial ingredient of
MDSE and allow the definition of mappings between different models.
Transformations are actually defined at the metamodel level, and then applied at
the model level, upon models that conform to those metamodels. The
transformation is performed between a source and a target model, but it is
actually defined upon the respective metamodels (see also Figure 2.7).
MDSE provides appropriate languages for defining model transformations
in order to provide designers with optimized solutions for specifying
transformation rules. These languages can be used for defining model
transformations in terms of transformation templates that are typically applied
upon models according to some matching rules checked upon model elements.
Such transformation rules can be defined following different approaches:
the transformation can be written manually from scratch by a developer, or can
be defined as a refined specification of an existing one. Alternatively,
transformations themselves can be produced automatically out of some higher
level mapping rules between models. This technique is based on two phases:
Some modeling tools use a concrete textual syntax for specifying models
(not all models need to be graphical models), and therefore, there is no support
for drawing them, even if the tools may be able to render the textual definition
into some kind of graphical export format for visualization purposes. For
instance, one can think about the textual modeling tools for UML2 or any of the
DSLs you may create with tools like XText3 and EMFText.4
Furthermore, many drawing tools are not appropriate modeling tools. A
drawing tool can be only considered as a modeling tool only if the tool
“understands” the drawings, i.e., the tool does not deal with just shapes, lines,
and arrows, but understands that they represent, e.g., classes, associations, or
other modeling concepts. This should at least be enough to validate a model, i.e.,
check that the model is a correct instance of its metamodel.
For instance, a drawing tool may allow the designer to draw something
funny like the model in Figure 2.9. The icons and shapes may be the ones
defined in a given language (in the example, the UML notation) but the model
may have no meaning at all, because the way elements are used breaks the
language rules. MDSE recommends always using a modeling tool to define
models because of at least three main reasons.
Despite the technical change that companies must face when embracing
MDSE, experts often think that the biggest challenges faced by companies
adopting model-driven approaches are not so much on the technical side, but
much more on the human factor side [34]. Here are some responses by well-
known experts in the field when asked about the biggest difficulty in embracing
MDSE, BPM, SOA, and similar practices:
• “dealing with people’s habits and resistance to change” (R. M. Soley,
OMG);
• “accepting and adopting standards” (S. White, IBM);
• “who to ask for guidance and training, and tools availability; difficulty of
communication between users, business lines, and other stakeholders” (A.
Brown, The Open Group);
• “dealing and managing people” (S. Mellor); and
• “impatience of getting to the results” (T. Jensen, IBM).
These aspects sum up to the well-known fact that: “Learning a new tool or
technique actually lowers programmer productivity and product quality initially.
You achieve the eventual benefit only after overcoming this learning curve” [29].
Despite the advantages of MDSE, one should not regard it as the panacea
for all the problems in the world. Some experts actually have some words of
caution about the MDSE approach and what it implies:
• Beware of statements of pure principles: when it comes down to it, the real
point of software engineering practice is to increase productivity, reduce
errors, and cut code [25]. When MDSE is not perceived as delivering such
properties, it is regarded with suspicion.
• Sometimes, the main message of MDSE is perceived as advocating
modeling with respect to programming. However, that is not the right way
to see it. The real question instead is to understand and define the right
abstraction level for addressing each development activity. At the end, this
applies also to programming itself.
• In the view of traditional programmers, diagrams are considered, after all,
just pretty pictures. As such, they represent more of a burden than an
advantage (as for documentation, they need to be kept aligned, discussed,
and so on). This opinion is mainly due to unclear understanding of modeling
(vs. drawing) and of its advantages, as we will discuss later in the book.
• Models may be perceived as an oversimplification of reality [63]. Indeed,
models are an abstraction of reality, where unnecessary details are omitted.
However, MDSE practices can be used to combine or refine models to cover
all the interesting aspects.
• Models are perceived as useless artifacts that nobody will appreciate,
including end users that just look for software that executes and performs
well. This is a way to express that models and running applications are
perceived as competitors, which is not true at all, especially if you consider
the concept of executable models, which can become such through code
generation or model-interpretation techniques.
• “To a Computer Scientist, everything looks like a language design problem.
Languages and compilers are, in their opinion, the only way to drive an idea
into practice” (David Parnas). This is a clear warning on how and when to
apply MDSE techniques for language definition. As we will see later when
addressing domain-specific languages, we also advise prudence in
embarking in a language definition task.
1We recognized that methodology is an overloaded term, which may have several interpretations. In this
context, we are not using the term to refer to a formal development process, but instead as a set of
instruments and guidelines, as defined in the text above.
2http://modeling-languages.com/uml-tools/#textual
3http://www.eclipse.org/Xtext
4http://www.emftext.org
5With the caveat that, as he said, he has been giving the same answer since 1985!
CHAPTER 3
The first and most known application scenario for MDSE is definitely the one of
software development automation (typically known as model-driven
development (MDD)) where model-driven techniques are consistently employed
with the goal of automating as much as possible the software lifecycle from the
requirements down to the deployed application. However, the full spectrum of
possible applications for MDSE spans a much wider set of scenarios; MDD is
just the tip of the MDSE iceberg (as shown in Figure 3.1).
In this sense, the acronym MD(S)E can also be read as Model-Driven
Everything; that is, the MDSE philosophy can be applied to any software
engineering task. This chapter will focus on three main application scenarios that
illustrate how the benefits of MDSE can apply to different needs. Apart from the
software development scenario, we will describe the application of MDSE to the
reverse engineering and software modernization field, to the tool/systems’
interoperability problem and we will touch as well the use of models in an
organization, beyond purely its software systems.
Figure 3.1: MDD is just the most visible side of MDSE.
The most well-known family of executable models are those based on the
UML language, generically referred as executable UML.4 Executable UML
models make extensive use of an action language (kind of imperative
pseudocode) to precisely define the behavior of all class methods, state
transitions, etc. The OMG itself has recently standardized this notion of
executable UML models. In particular, the OMG has standardized the semantics
of a Foundational Subset for Executable UML Models (fUML) that suffices to
model software specifications in a way that makes them suitable to be the input
of an automated software development process. The adopted action language for
fUML is known as the Action Language for fUML, or Alf.5 Alf is basically a
textual notation for UML behaviors that can be attached to a UML model at any
place a fUML behavior can be. Syntactically, Alf looks at first much like a
typical C/C++/Java legacy language, which softens its learning curve.
Code generation and model interpretation are then two different alternative
strategies to “implement” execution tools and thus make executable models
actually execute.
Syntactic Mapping
Syntactic mapping aims at crossing different technical spaces. The idea is to use
projectors to go from a generally heterogeneous world (in terms of formats,
techniques, etc.) to a more homogeneous world, in our case the modeling world
of MDSE, and vice versa. Once in the modeling world, models can be used as
the lingua franca between tools. These projectors can be directly hard coded
using a general-purpose language such as Java, or preferably implemented with
model-to-text or text-to-model transformation technologies (assuming that the
input/output files are in text format), as those which we will see in the next
chapters.
As mentioned in Chapter 2, there are two kinds of projectors:
• injectors that allow “injecting” the content of input files, using dedicated
formats, as models (e.g., to transform the input file a1 into model a1 in
Figure 3.5); and
Figure 3.5: Generic interoperability bridge between two systems.
• extractors that allow “extracting” the content of models as output files using
dedicated formats (e.g., to generate the output file b1 from model b1 in
Figure 3.5).
Semantic Mapping
Semantic mapping aligns the concepts coming from the domains of both
systems. This mapping is implemented as a model-to-model transformation. The
transformation re-expresses the domain concepts of system A into a set of
equivalent domain concepts understandable by system B. Metamodels A and B
can be manually generated, derived from the corresponding format description
(e.g., an XML schema when the input or output are XML documents), or
automatically created if the formats to bridge conform to a meta-format for
which a bridge at the metametalevel is already available. For instance, a generic
bridge between the XML schema language and the MDSE meta-metamodel
would allow an automatic transformation of all format descriptions, i.e., specific
XML schemas, to metamodels.
1As we will discuss later on, this is just an example. In some contexts we can go directly from the analysis
models to the code or, when using model interpretation, skip the implementation phase and execute
directly the models.
2This doesn’t mean that all models created during the process have to be executable but at least some of
them must.
3Note that this is the strategy that many MVC frameworks for popular languages like Ruby, PHP, or
Python already follow; frameworks like Ruby on Rails, Symfony or Django automatically create a
production-ready administration web interface based on the model’s definition.
4Executable UML is also used to refer to the specific executable UML development method (xUML)
proposed by S. Mellor [48] as an evolution of the previous Shlaer-Mellor method.
5See http://www.omg.org/spec/ALF for the Alf Language specification or
http://modeling-languages.com/new-executable-uml-standards-fuml-and-
alf for a short introduction by Ed Seidewitz, the main language designer.
6http://en.wikipedia.org/wiki/Turing_test
7Models at runtime are also heavily employed in self-adaptive systems, i.e., systems that monitor the
environment and are able to modify its behavior in response to changes on the environmental conditions.
The information about how to adapt to these changes is usually expressed as a model that it is interpreted
by the system at runtime.
8See also the discussion thread in:
http://www.theenterprisearchitect.eu/archive/2010/06/28/model-driven-
development-code-generation-or-model-interpretation.
9http://www.eclipse.org/MoDisco
10http://www.omg.org/spec/BPMN
11http://www.zachman.com/about-the-zachman-framework
12http://pubs.opengroup.org/architecture/togaf9-doc/arch
CHAPTER 4
The Object Management Group (OMG) has defined its own comprehensive
proposal for applying MDE practices to systems development. This goes under
the name of MDA (Model-Driven Architecture) [55]. We take MDA as a good
exemplary MDE framework for two main reasons: first, MDA is a perfect case
for explaining the MDE concepts introduced so far, as all the standard phases of
a software development process such as analysis, design, and implementation are
appropriately supported; second, given the importance of the OMG in the
software industry, MDA is currently the most known modeling framework in
industry. Without the aim of being complete, we report here some of the main
contributions of the approach, which have become common knowledge and may
ease the understanding of MDE in general.
MDA itself is not an OMG specification but rather an approach to system
development which is enabled by existing OMG specifications, such as the
Unified Modeling Language™ (UML®), the Meta Object Facility (MOF™), the
UML Profiles SysML, SoaML, MARTE, and the CORBA® Component Model
(CCM), among others.
The four principles that underlie the OMG’s view of MDE are the
following:
• Models must be expressed in a well-defined notation to foster effective
communication and understanding of system descriptions for enterprise-
scale solutions.
• Systems specifications must be organized around a set of models and
associated transformations implementing mappings and relations between
the models. All this enables a systematic design based on a multi-layered
and multi-perspective architectural framework.
• Models must be built in compliance with a set of metamodels, thus
facilitating meaningful integration and transformation among models and
automation through tools.
• This modeling framework should increase acceptance and broad adoption of
the MDE approach and should foster competition among modeling tool
vendors.
As you can see, these official definitions are perfectly in line with the ones given
in the introductory chapters on MDE and actually they represent the concrete
incarnation and interpretation given by OMG to the various aspects of system
definition. Based on these definitions, OMG proposes a whole modeling
approach spanning methods, languages, transformations, and modeling levels.
This chapter does not aim at providing a comprehensive coverage of the MDA
framework. Instead, it is more aimed at giving an overview to the approach so as
to let the reader understand the possibilities and potential usages.
4.2 THE MODELING LEVELS: CIM, PIM, PSM
As we introduced in Chapter 1, the level of abstraction of models can vary
depending on the objectives of the models themselves. In MDA, three specific
levels of abstraction have been defined, as shown in Figure 4.1.
• Computation-Independent Model (CIM): The most abstract modeling level,
which represents the context, requirements, and purpose of the solution
without any binding to computational implications. It presents exactly what
the solution is expected to do, but hides all IT-related specifications, to
remain independent of if and how a system will be (or currently is)
implemented. The CIM is often referred to as a business model or domain
model because it uses a vocabulary that is familiar to the subject matter
experts (SMEs). In principle, parts of the CIM may not even map to a
software-based implementation.
Figure 4.1: The three levels of modeling abstraction codified in MDA: computation-independent (CIM),
platform-independent (PIM), and platform-specific (PSM) models.
Figure 4.2: CIM example: the description of the business processes performed within an organization.
4.3 MAPPINGS
Generally speaking, a mapping consists of the definition of the correspondences
between elements of two different models. Typically, a mapping is specified
between two metamodels (i.e., modeling languages), in order to automate the
transformations between the respective models. For instance, if the PIM level is
described by a Petri Net, while the PSM is described by some UML dynamic
diagram, the mapping must associate the concepts of Petri Nets with the
corresponding ones in the UML diagram. Mappings between the metamodels
allow us to build mappings between models, i.e., the traces (as described in
Chapter 8). Mappings defined at the metamodel level are called intensional,
while mappings defined at the model level are called extensional (because they
are defined on the extension, i.e., instances, of the metamodel).
Figure 4.3: PIM example: the definition of a concept (Account), its properties, and constraints to be
considered for any system implementation dealing with that concept.
1The difficulties of introducing an application/process that provides a collective benefit but not a uniform
individual benefit is well known, e.g., see [31] for a study for the groupware domain.
2http://agilemanifesto.org
3http://www.agilemodeling.com
CHAPTER 6
Modeling languages are conceptual tools with the purpose of letting designers
formalize their thoughts and conceptualize the reality in explicit form, be it
textual or graphical. This chapter describes the main features of modeling
languages, considering the peculiarities of general-purpose languages (GPLs),
domain-specific languages (DSLs), and the intermediate solutions that allow the
customization of GPLs for specific purposes.
Figure 6.1: The three main ingredients of a modeling language (semantics, abstract syntax, and concrete
syntax) and their relationships.
Notice that UML is just a modeling language, and does not enforce any
particular development method. UML is often mentioned together with the
Unified Process (UP), best known in its specialization called Rational Unified
Process (RUP). RUP is an iterative software development process framework
created by Rational Software Corporation (now a division of IBM). While RUP
and UML work very well together, the adoption of RUP is not necessary for
using UML.
UML has a long history which comprises merges of several pre-existing
approaches and subsequent restructuring of its specifications. Some pieces of
UML, such as Harel’s statecharts and Booch’s notations, date back to the mid-
1980s. At that time, a plethora of different notations existed. However, the first
version of UML was conceived only in 1996, born from the fusion of the
approaches of Booch, Rumbaugh, and Jacobson. This proposal was discussed at
the OOPSLA conference in 1996. Other integrations followed and led to the
submission of UML to OMG in August 1997 and the official release as an OMG
standard in November 1997 (as UML 1.1). The long and controversial history of
UML is accountable for the complexity and also some inconsistencies of the
language that hold still today. However, despite some important and motivated
criticisms to the language, UML remains a unifying language for software
modeling.
Figure 6.3: Dichotomy between class- and instance-based models in UML.
• State machine diagram (or statechart): Describes the states and state
transitions of the system, of a subsystem, or of a specific object. In general,
state machines are suitable for describing event-driven, discrete behavior,
but are inappropriate for modeling continuous behavior. The example in
Figure 6.7 shows the states of a product with respect to the shipping and
invoicing aspects, and the transitions that lead from one state to another.
Transitions may have associated conditions (e.g., whether the item is the last
of the shipment or not). Please notice that in statecharts the nodes represent
states (while in activity diagrams they represented actions).
• Interaction diagrams: A subset of behavior diagrams which emphasizes the
flow of control and data among the elements of the system. This set
comprises the following diagrams.
1. Sequence diagram: Shows how objects communicate with each other
in terms of a temporal sequence of messages. The time dimension is
the most visible aspect in these kinds of diagrams, as messages are
sequenced according to a vertical timeline, and also the lifespan of
objects associated with those messages is reported. Figure 6.8 shows an
example sequence diagram describing three objects (instances of
classes Shipment, Invoice, and Product) and the messages exchanged
between each other for printing an invoice. Interaction diagrams
describe execution scenarios of the system.
6.5.1 STEREOTYPES
Stereotypes are used to extend meta-classes by defining additional semantics to
the concept represented by the meta-class. Notice that the same model element
may be stereotyped in multiple different ways. Stereotypes can be defined by
specifying the following properties:
• Base metaclasses, defining what element(s) is going to be extended.
• Constraints, defining the special rules and semantics that apply to this
specialization. This is what characterizes the stereotype in terms of
semantics.
• Tagged values, defining zero or more values that the stereotype may need to
know for working properly.
• Icon, defining the visual appearance of the stereotyped elements in the
diagrams.
One doubt that may arise is why one should not use standard sub-classing
instead of stereotyping. Indeed, this is an option, but the effect is quite different.
Subclassing is a core operator of UML and basically defines a special relation
between two items in the same model. Stereotypes instead let the designer define
new modeling concepts, which in turn will be used for creating models.
Stereotypes are typically used when you want to define (i) additional semantic
constraints that cannot be specified through standard M1-level modeling
facilities, (ii) additional semantics which may have significance outside the
scope of UML (e.g., metadata such as instructions to a code generator), or (iii)
the need arises for defining a new modeling concept which has some specific
behavior or properties and which will be reused often in the modeling process.
6.5.2 PREDICATES
Another possibility for varying the semantics of UML is to apply restriction
predicates (e.g., OCL expressions, as we will see at the end of this chapter) that
reduce semantic variation of a modeling element. Predicates can be attached to
any meta-class or stereotype in UML and can consist of formal or informal
expressions. To be coherent with the standardized meaning of the UML symbols,
the expressions must not contradict the inherited base semantics of the elements.
While designers can define their own profiles, several UML profiles have
been standardized and are widely recognized and used. Some examples of well-
known profiles that became standards in OMG (we already mentioned them in
Chapter 4 without highlighting they were UML profiles) are the following ones:
• UML Testing Profile (UTP): A UML profile that provides extensions to
UML to support the design, visualization, specification, analysis,
construction, and documentation of the artifacts involved in testing.
• OMG Systems Modeling Language (SysML).
• Service-oriented architecture Modeling Language (SoaML).
• UML Profile for System on a Chip (SoCP).
• UML Profile for Schedulability, Performance, and Time.
• UML Profile for Modeling and Analysis of Real-time and Embedded
Systems (MARTE).
The complete list is available online on the OMG website.8
Classification of DSLs
DSLs can be classified according to various dimensions, namely focus, style,
notation, internality, and execution.
Focus
The focus of a DSL can be either vertical or horizontal. Vertical DSLs aim at a
specific industry or field. Examples of vertical DSLs may include: configuration
languages for home automation systems, modeling languages for biological
experiments, analysis languages for financial applications, and so on. Horizontal
DSLs have a broader applicability and their technical and broad nature allows
for concepts that apply across a large group of applications. Examples of
horizontal DSLs include SQL, Flex, IFML,9 WebML,10 and many others.
Style
The style of a DSL can be either declarative or imperative. Declarative DSLs
adopt a specification paradigm that expresses the logic of a computation without
describing its control flow. In other words, the language defines what the
program should accomplish, rather than describing how to accomplish it. A
typical example of declarative definition is the one of service choreography,
which defines the one-to-one rules for Web service coupling. Imperative DSLs
instead specifically require defining an executable algorithm that states the steps
and control flow that needs to be followed to successfully complete a job. A
typical example of imperative definition is the one of service orchestration,
where a start-to-end flow of execution is defined between Web services.
Notation
The notation of a DSL can be either graphical or textual. The graphical DSLs
imply that the outcomes of the development are visual models and the
development primitives are graphical items such as blocks, arrows and edges,
containers, symbols, and so on. The textual DSLs comprise several categories,
including XML-based notations, structured text notations, textual configuration
files, and so on.
Internality
As defined by Martin Fowler, external DSLs have their own custom syntax; you
can write a full parser to process them, and you write self-standing, independent
models/programs using them.
Internal DSLs instead consist in extending a host language to give the feel
of a particular domain or objective to the host. This can be obtained either by
embedding pieces of a DSL in the host language or by providing abstractions,
structures, or functions upon it. Thanks to the embedding, you can reuse all the
host language tooling and facilities.
entity mux4_to_1 is
port (I0,I1,I2,I3: in std_logic_vector(7 downto 0);
SEL: in std_logic_vector (1 downto 0);
OUT1: out std_logic_vector(7 downto 0);
end mux4_to_1;
Execution
As already discussed in Chapter 3, executability can be implemented through
model interpretation (or code generation). Model interpretation consists in
reading and executing the DSL script at run-time one statement at a time, exactly
as programming languages interpreters do. Code generation instead consists of
applying a complete model-to-text (M2T) transformation at deployment time,
thus producing an executable application, as compilers do for programming
languages.
This is where Object Constraint Language (OCL) comes into play. OCL is a
general-purpose (textual) formal language adopted as a standard by the OMG.12
OCL is a typed, declarative and side effect–free specification language. Typed
means that each OCL expression has a type, evaluates to a value of that type, and
must conform to the rules and operations of that type. Side effect-free implies
that OCL expressions can query or constraint the state of the system but not
modify it. Declarative means that OCL does not include imperative constructs.
And finally, specification refers to the fact that the language definition does not
include any implementation details nor implementation guidelines.
OCL is used to complement metamodels with a set of textual rules with
which each model conforming to that metamodel must comply.13 When applied
to a metamodel, these modeling constraints are also known as well-formedness
rules since they define the set of well-formed models that can be specified with
that specific modeling language.
Constraints in OCL are represented as invariants defined in the context of a
specific type, named the context type of the constraint. Its body, the boolean
condition to be checked, must be satisfied by all instances of the context type.
The standard OCL library predefines the primitive and collection-related types
(and their operations) that can be used in the definition of an OCL expression.
Quantifiers (like for all and exists) and other iterators (select, reject, closure,
etc.) are also part of the library. Access to the properties of an object and
navigations from an object to its related set of objects (via the associations
defined in the metamodel) is done using the dot notation. An introductory OCL
tutorial can be found in http://modeling-languages.com/object-constraint-
language-ocl-a-definitive-guide.
Some simple exemplary OCL expressions are reported below to let the
reader appreciate the flavor of the language. Suppose we are describing a system
for enterprise meeting planning, as represented in Figure 6.14, where the
relevant classes are Meeting (comprising the attributes for describing start and
end date/time and the isConfirmed attribute specifying whether the meeting is
confirmed or not), Team, and TeamMembers (i.e., the people belonging to the team).
Figure 6.14: UML class diagram describing enterprise meetings (basis for the OCL examples).
The following invariant expression declares that for every Meeting instance
the attribute end must be greater than the attribute start:
context Meeting
inv: self.end > self.start
The next expression defines the derived attribute size in Team representing the
number of members in the team:
context Team::size:Integer
derive: self.members->size()
Notice that the above rule uses oclIsTypeOf to check the type of the meeting.
Another (more sensible) option would be to define the rule directly in the
context of TeamMeeting.
Finally, the next example defines how the result of the method
numConfMeeting(), determining the number of confirmed meetings of a
TeamMember, is calculated. This is defined by using the post-condition operator
(post).
context TeamMember::numConfMeeting():Integer
post:
result=meetings->select(isConfirmed)->size()
1In the modeling realm, domain-specific languages (DSLs) are sometimes called DSMLs just to
emphasize that they are modeling DSLs. However, DSL is by far the most adopted acronym and therefore
we will stick to it in the upcoming discussions.
2Same discussions of DSL vs. DSML applies to GPML. We will use GPL for simplicity.
3http://modeling-languages.com/uml-mdl-many-domains-language
4http://martinfowler.com/bliki/DslBoundary.html
5The last official version of UML can always be retrieved at: http://www.omg.org/spec/UML.
6http://en.wikipedia.org/wiki/List_of_UML_tools
7See, for instance: http://modeling-languages.com/ivar-jacobson-reflecting-
evolution-uml, http://modeling-languages.com/grady-boochs-comments-
umlmda, http://modeling-languages.com/uml-30-not-yet-or-so-it-seems,
http://modeling-languages.com/complexity-uml.
8http://www.omg.org/spec/#Profile
9http://www.ifml.org
10http://www.webml.org
11A multiplexer (MUX) is an electronic component that selects one of several analog or digital input
signals and forwards the selected input into a single line. See more at:
http://en.wikipedia.org/wiki/Multiplexer.
12OCL Specification. http://www.omg.org/spec/OCL
13As we will see throughout the book, OCL plays a key role in many other MDSE techniques, e.g., as part
of the definition of matching patterns for model transformations.
CHAPTER 7
Modeling has been often misunderstood as the process of just drawing pretty
pictures. However, as we have already mentioned, models are much more than
just pretty pictures. Models have to follow a clearly defined structure (exactly
like program code), i.e., they have to conform to the associated metamodel
representing the abstract syntax of the modeling language. Having a well-
defined structure is the basis for applying operations on models such as
loading/storing models from/to model repositories, querying and transforming
the content of models, and checking the well-formedness of models to name just
a few possible operations. In several modeling environments and tools, which
use models as sketches or which were not built based on MDE practices,
metamodels have a secret life hidden behind the user interface of the tools and,
thus, are often invisible for the modelers. In simple usage scenarios, designers
may not need to have a clear understanding of what is going on behind the
curtains, but for complex MDE scenarios it is important to understand the big
picture of MDE design. Especially, if you build your own tailored MDE
environment, developing and using a metamodel is crucial, as we will see in this
chapter. The main reason for this is that other language aspects going beyond the
language’s abstract syntax, such as the definition of the visual notation to be
used when modeling, are heavily based on metamodels.
Language purpose. sWML should allow the modeling of the content layer and
the hypertext layer of Web applications. The content layer defines the schema of
the persistent data which is presented to the user by the hypertext layer in form
of Web pages. In addition, the hypertext layer defines the navigation between
Web pages and the interaction with the content layer, e.g., querying content from
the database.
Language realization. To support different sWML user types, a graphical
syntax should be defined which may be used for discussing with domain experts
and for reasoning on the structure of the hypertext layer and the content layer.
However, for making a smooth transition from the standard development process
based on programming languages to the model-driven approach, additionally, a
textual syntax should be provided for developers who are familiar and used to
working with text-based languages.
Language content. A sWML model consists of a content layer and a hypertext
layer which reflects the previously mentioned purpose of the language.
A content model contains an unrestricted number of classes. Classes have a
unique name (e.g., Tutorial) and multiple attributes (e.g., Tutorial.title).
Attributes have an assigned name and type. For instance, permitted types are:
String, Integer, Float, Boolean, and Email. For each class, one attribute has to be
selected as the representative attribute which is not explicitly indicated in the
concrete syntax to keep the syntax concise.
Hypertext models contain different kinds of pages, whereas each page has a
name. Exactly one page is the homepage of the Web application. Later on, this
page (and all directly linked pages of the homepage) can be accessed by all other
pages of the Web application. Pages are subdivided into static and dynamic
pages. Static pages represent only static content, e.g., a collection of useful links.
In contrast, dynamic pages represent dynamically generated content coming
from the database. Thus, a dynamic page always has a relationship to a class
defining the type of the displayed instances. The relationship to the used classes
is shown in parentheses under the name of the page. Dynamic pages are further
subdivided into details pages and index pages having specific icons. Index pages
show all instances of a class in terms of a list, e.g., a list consisting of all
tutorials of the conference, showing only the representative attribute of the
instances. In contrast, details pages always show exactly one instance, e.g., one
tutorial, with all its attributes.
Links represent the navigation between pages by pointing from a source
page to a target page. On the source page, the link is visualized to the user. Thus,
a page usually knows its links pointing to other pages but it is unaware of
incoming links. Two kinds of links are distinguished: (i) non-contextual links
(NCLinks) are standard links, which do not transport any information, e.g., a
link to a static page; and (ii) contextual links (CLinks) transport information to
the target page, e.g., to transfer data needed to compute the content of the target
page, e.g., to select the instance shown by a details page.
Essence of the abstract syntax. The first version of the language content
description comprises different kinds of information. Primarily, the modeling
concepts are introduced by defining their properties which is a necessary input
for developing the abstract syntax. But sometimes other aspects such as the
notation and semantics of the modeling concepts are discussed. Thus, from this
description, the essence of the abstract syntax has to be filtered out, before the
first version of the metamodel can be built. As a result, a list of concepts and
their properties is produced. For our example, the table shown in Figure 7.4
summarizes the most important sWML concepts and their properties. In
particular, intrinsic properties, having only primitive data values, must be
distinguished from extrinsic properties, which represent relationships between
modeling concepts.
Step 2: Modeling Language Design
The modeling concept table shown in Figure 7.4 guides the design of the
metamodel as illustrated in Figure 7.5 for sWML. First, concepts are
transformed to classes, intrinsic properties into attributes, and extrinsic
properties are defined as associations between classes. Having this initial
structure, one can reason about further modeling constraints. For attributes, types
have to be introduced such as String, Integer, and Boolean. If there is a range of
possible values, enumerations may be defined as for the SWMLTypes (cf. Figure
7.5). For the association ends, upper and lower bounds of multiplicities have to
be set properly.
Rule 1: A Class must have a unique name within the Content Layer to avoid
name clashes.
context ContentLayer inv:
self.classes -> forAll(x,y | x <> y implies x.name <> y.name)
Rule 2: The representative Attribute of a Class must be taken out of the set of
Attributes contained by the Class.
context Class inv:
self.attributes -> includes(self.representativeAttribute)
Rule 3: A page must not contain a non-contextual link to itself, because
navigating such a link would result in exactly the same page as shown before the
navigation.
context Page inv: not self.links -> select(l | l.oclIsTypeOf(NCLink))
-> exists (l|l.target = self)
This last example requires that a class should not have more than six attributes:
context Class inv: self.attributes -> size() < 7
OCL support for Ecore. For defining OCL constraints for Ecore-based
metamodels several plugins are available in Eclipse. Eclipse OCL10 is a project
focusing—as the name suggests—on the implementation of the OCL standard
within Eclipse. An interesting subcomponent in this project is OCLinEcore11
which allows the definition of invariants for Ecore-based metamodels and the
evaluation of these constraints within modeling editors. An alternative project is
the Dresden OCL Toolkit.12 Further support for defining and evaluating
invariants for EMF-based models is provided by the Epsilon Validation
Language13 of the Epsilon project. The languages are inspired by OCL, but
provide a slightly different syntactic appearance related to Java, as well as syntax
extensions useful for practical aspects of model validation such as customizable
error messages.
By taking a closer look at this example, the following kinds of TCS elements can
be identified which are of paramount importance for every TCS, in general.
• Model information: Obviously, a TCS has to support the model
information stored in the abstract syntax. In our example, we have to define
the name of the model elements and for attributes also the type. This is
analogous to graphical languages where labels are normally used for stating
such information.
• Keywords: A keyword is a word that has a particular meaning in the
language, i.e., it stands for a particular language construct. In our example,
keywords are used for introducing the different model elements. The terms
used for representing keywords are reserved words and cannot be used as
values for model elements. For example, a class called class would not be
possible without using special markers which eliminate the keyword
character of the term.
• Scope borders: In a GCS, a figure defines the borders of a model element.
In a TCS no figures are used but instead special symbols, so-called scope
borders are used to mark the beginning and the end of a certain section. In
our example, curly brackets well known from programming languages are
used as scope borders. After introducing an element by its keyword, an
opening curly bracket and a closing curly bracket are used to define the
compartments of the element. Thus, the scope borders are also of special
importance for nesting elements in a TCS.
• Separation characters: In a textual artifact a list of elements may be
specified at a certain position. In such cases, a special character is needed
for separating the entries of the list. In our example, we are using the semi-
colon to separate the different attributes introduced for a class.
• Links: In a GCS, edges are used to link different elements related by non-
containment references. In a textual language, we only have one dimension
to define elements. Thus, links which are not defined as containments
cannot be explicitly visualized. To specify links, identifiers have to be
defined for elements which may be used to reference an element from
another element by stating the identifier value—similar to the foreign key
concept in relational databases. In our example, the page has to be linked to
a class of the content layer. Thus, the class has to provide an identifier. A
natural identifier of the class is its name, as it is known from programming
languages to use class names as types.
Approaches to TCS development. Besides the model information, metamodels
do not provide information about the other kinds of TCS elements. For the
definition of this TCS specific information, two approaches are currently
available in MDE: (i) having either a generic TCS or (ii) a language-specific
TCS.
Generic TCS. Such as for XML, a generic TCS may be also defined for models.
This means, similar to using object diagrams to graphically visualize models in a
generic way, a textual syntax generically applicable for all kinds of models may
be applied. You can think of this textual syntax as a textual format for specifying
object diagrams. The benefit is that the metamodel is sufficient to derive a TCS,
i.e., no additional concrete syntax specification is needed. A drawback is that no
tailored syntax can be developed dealing with the specifics of a given modeling
language.
This approach has been used to define the XMI syntax for serializing
models into XML documents as well as the Human Usable Textual Notation
(HUTN), both standardized by the OMG. An implementation of the HUTN
standard is provided for EMF by the Epsilon HUTN project.23 How models are
generically serialized into XML documents is presented in Chapter 10.
Defining a TCS for sWML in Xtext. We selected Xtext for demonstrating the
development of a TCS, because of its mature tool support within Eclipse. Xtext
provides a grammar definition language similar to EBNF, but with additional
features to achieve a similar expressivity as metamodeling languages such as
Ecore. This is an important extension, because from the grammars, metamodels
are automatically generated which should exploit all possibilities of
metamodeling languages to produce high-quality metamodels. Having a
metamodel, a grammar, model-to-text serializer, and text-to-model parser for a
modeling language allows a smooth transition from text to models and vice
versa. Thus, having a language defined with Xtext allows the use of all the tool
support available for EMF-based models such as model transformations, code
generation, etc.
Besides the interoperability between text-based and model-based
representations, a text-based editor is automatically generated from the grammar
definition. The generated editor supports syntax checking and highlighting, code
completion, and well-defined extension points to further enhance the editing
functionality programmatically using Java. Context-sensitive constraints are
described in an OCL-like language called Check which are formulated against
the automatically generated metamodel.
Text production rules comprise the core of Xtext-based grammars. In
particular, three kinds of production rules are distinguished.
• Type rules: Type rules are the counterpart of classes in metamodels and are
used to define modeling concepts. Consequently, when generating a
metamodel from an Xtext-based grammar, a corresponding class in
metamodels is produced, whereas the name of the rule corresponds to the
name of the class. Type rules contain (i) terminals which represent the
keywords, scope borders, and separation characters of the language and (ii)
non-terminals. Non-terminals can be further distinguished into assignments
which are mapped to attributes or containment references, and cross
references which are mapped to non-containment references when a
metamodel is generated from the grammar. So to speak, the non-terminals
represent the features of a type rule. Thus, for each non-terminal, a feature is
generated in the corresponding metamodel class. For defining assignments,
several operators are available for setting the multiplicities of the features.
• Terminal rules: Such rules are similar to EBNF rules and are used to just
return a value, i.e., a sequence of characters. In contrast to EBNF rules,
terminal rules may have an assigned return type such as String or Integer.
• Enum rules: These rules are used for defining value enumerations. Thus,
they are simply transformed to EEnums in the corresponding metamodels.
In the following, we demonstrate the use of type rules, terminal rules, and enum
rules by defining an excerpt of the TCS definition for sWML (cf. Listing 7.1)
which is sufficient for rendering the example model shown in Figure 7.13.
WebModel :
'webapp' name=ID '{'
hypertext=HypertextLayer
content=ContentLayer
'}' ;
HypertextLayer :
'hypertext {'
pages+=IndexPage+
'}' ;
IndexPage :
'index' name=ID 'shows' displayedClass=[Class] '[' resultsPerPage ']' '{' ... '}' ;
ContentLayer :
'content {'
classes+=Class+
'}' ;
Class :
'class' name=ID '{' attributes+=Attribute+ '}' ;
Attribute :
'att' name=ID ':' type=SWMLTypes ';' ;
enum SWMLTypes :
String | Integer | Float | Email | Boolean ;
7.5.1 REQUIREMENTS
Four main requirements need to be addressed when defining a language that
aims at becoming widely used and adopted:
• Definition of the language based on standard modeling frameworks;
• Definition of the language features by keeping into account the usability
and simplicity of adoption, besides the coverage of the domain
requirements;
• Capability of integration with other modeling perspectives, typically by
allowing referencing to modeling elements or whole diagrams specified
using other languages;
• Extensibility of the language through appropriate and limited extension
points that allow us to cover specific domain or enterprise needs, without
distorting the nature of the language; and
• Support for reuse of modeling elements, so as to allow for minimal
redundancy in models.
Figure 7.16: IFML Metamodel excerpt: ViewElement and its hierarchy (and containment).
1In programming languages, EBNF-based grammars [35] are used for this purpose.
2For instance, the English grammar defines all valid English sentences; the Java grammar defines all valid
Java programs.
3Please note that graphical languages often comprise textual elements, e.g., in UML state machines the
names of the states are rendered as text. Furthermore, there are also hybrid approaches for rendering the
abstract syntax using textual elements such as supported by MPS, see:
http://www.jetbrains.com/mps.
4http://www.mdse-book.com
5https://eclipse.org/modeling/emf
6http://www.mdse-book.com
7http://www.eclipse.org/modeling/emft/?project=ecoretools
8http://wiki.eclipse.org/KM3
9http://wiki.eclipse.org/Emfatic
10http://www.eclipse.org/modeling/mdt/?project=ocl
11http://wiki.eclipse.org/MDT/OCLinEcore
12http://www.dresden-ocl.org
13http://www.eclipse.org/epsilon/doc/evl
14www.omg.org/spec/DD
15Mappings may be conditional, meaning that the selection of the element used for visualization depends
on some feature values of the model elements.
16http://www.eclipse.org/gmf
17The tool palette is the area of a modeling tool offering icons for populating the modeling canvas by
dropping elements into it.
18http://www.eclipse.org/sirius
19http://www.eclipse.org/gmt/epsilon/doc/eugenia
20http://www.eclipse.org/graphiti
21http://www.eclipse.org/gef
22For the sake of simplicity, we do not discuss the complete GCS specification for pages such as icons, etc.
23http://www.eclipse.org/epsilon/doc/hutn
24http://www.eclipse.org/gmt/tcs
25http://www.emftext.org
26http://www.eclipse.org/Xtext
27Xtext has been extended to allow also for a metamodel first development approach by generating a
default TCS from a metamodel.
28http://www.monticore.org
29http://www.omg.org/spec/IFML
CHAPTER 8
Model-to-Model Transformations
Models are neither isolated nor static entities. As part of an MDE process,
models are merged (to homogenize different versions of a system), aligned (to
create a global representation of the system from different views to reason about
consistency), refactored (to improve their internal structure without changing
their observable behavior), refined (to detail high-level models), and translated
(to other languages/representations, e.g., as part of code generation or
verification/simulation processes).
All these operations on models are implemented as model transformations
[61], either as Model-to-Model (M2M) or Model-to-Text (M2T) transformations
(the latter is the topic of the next chapter). In the former, the input and output
parameters of the transformation are models, while in the latter, the output is a
text string. Analogously, Text-to-Model (T2M) transformations have a text string
as input and a model as output; such transformations are typically applied in
reverse engineering (cf. Chapter 3).
During the last decade, many efforts have been spent in designing
specialized languages for specifying M2M transformations, ranging from textual
to visual; declarative to imperative; and semi-formal to formal. We review most
of them in the next sections and focus on two protagonists of different categories
to illustrate the main characteristics of transformation languages.
In Listing 8.1, we have defined two matched rules to implement the aforestated
requirements. The first rule is responsible for transforming instances of
sWML!Class into instances of sMVCML!Class and sMVCML!DAO. Thus, this rule has a
simple input pattern (cf. keyword from) matching for all instances of the
metaclass sWML!Class. The output pattern of this rule (cf. keyword to), creates
for each match, an sMVCML!Class instance and an sMVCML!DAO instance by using
two corresponding output pattern elements. The bindings of the output pattern
elements are straightforward. The names of the input pattern elements (e.g., c1)
are used to access the input pattern elements in the bindings of the output pattern
elements to retrieve necessary information of the input model to build the output
model. By this, the names of the classes contained in the input model can be
transferred to the output model (name <- c1.name). Furthermore, output pattern
elements may be directly linked in the output pattern by using again the names
of the output pattern elements in the bindings, e.g., class <- c2.
For transforming IndexPages instances into Controller and View instances,
the second rule is introduced. This rule has again a simple input pattern having
only one element and an output pattern comprising again two elements. The
bindings of the output pattern elements are again straightforward, except the
binding for the reference Controller.dao. The reason why this binding is more
complex is that a Controller instance has to refer to a DAO instance which is
created by another rule. Thus, we do not have a direct pointer to this target
element as before when linking the DAO and the Class instances which are both
created in the first rule. To link to a target element which is created by a different
rule, we have to resolve the target element for a given source element. For this,
ATL provides a specific operation called resolveTemp which is able to retrieve
produced target elements for a given source element. Thus, for linking the
Controller to the DAO, we make use of this operation to get the produced DAO
instance for the Class instance which is linked by the IndexPage. Please note that
for simple cases the resolveTemp operation does not have to be used explicitly. In
such cases the element produced by the first output pattern element is
automatically retrieved. More information on the resolveTemp operation is
presented in the following part which describes the execution phases of ATL.
These phases have a major impact on the point in time when target elements are
actually resolved. In contrast, linking instances which are produced by the same
rule is much simpler. Only the variable of the output pattern element has to be
used as value for the binding (e.g., crtl <- c). Please be aware that for
computing the title of View instances, a dedicated helper is introduced which is
called in the binding for setting the title attribute. This helper may be seen as a
derived attribute for the IndexPage class.
-- implementation of requirement 1
rule Class2Class_DAO {
from
c1 : sWML!Class
to
c2 : sMVCML!Class (
name <- c1.name
),
d : sMVCML!DAO (
name <- c1.name + 'DAO ',
class <- c2
)
}
-- implementation of requirement 2
rule IndexPage2Controller_View {
from
p : sWML!IndexPage
to
c : sMVCML! Controller (
op <- #retrieveAll ,
dao <- thisModule.resolveTemp(p.displayedClass , 'd')
),
v : sMVCML!View(
title <- p.title ,
ctrl <- c
)
}
Phase 1: Module initialization. In the first phase, among other things, the trace
model for storing the trace links between source and target elements is
initialized. In the subsequent phase 2, each execution of a matched rule will be
stored in the trace model by creating a trace link pointing to the matched input
elements and to the created output elements. As we will see later, the trace model
is an important concept for exogenous transformations: (i) to stop the execution
of a transformation and (ii) to assign features of the target elements based on
values of the source elements.
Example: In our example, simply the trace model is initialized in this phase
as illustrated in the left-hand side of Figure 8.3.
Phase 3: Target elements initialization. In the third phase, each allocated target
model element is initialized by executing the bindings that are defined for the
target pattern element. In the bindings, invocations of the resolveTemp operation
are quite common. This operation allows for the reference to any of the target
model elements which have been generated in the second execution phase for a
given source model element. It has the following signature:
resolveTemp(srcObj:OclAny,targetPatternElementVar:String). The first
parameter represents the source model element for which the target model
elements have to be resolved. The second parameter is the variable name of the
target pattern element which should be retrieved. The second parameter is
required, because it is possible to generate several target elements for one source
element by using multiple target pattern elements in one rule as it is the case in
our example. Thus, when a source model element has to be resolved, the variable
of the target pattern element which has produced the requested target element
has to be given.
Example: In our example, some bindings are simple, meaning that only
target model elements produced within one rule are linked or the matched source
model elements contain directly the information (such as attribute values)
needed for setting the features of the target model elements. However, there is
one binding which makes use of the resolveTemp operation
(resolveTemp(p.diplayedClass,'d')). Before the resolveTemp operation is
executed, the displayed class for the matched page is queried by evaluating the
first parameter of the operation. Subsequently, by executing the resolveTemp
operation, the trace link for the displayed class is automatically retrieved, and
finally, the variable names of the output pattern elements are used to retrieve the
actual requested target element (specified by the second parameter of the
operation) from the set of linked target elements ({'c2','d'}) of the trace link.
You can think of retrieving the output element by navigating from the trace link
to the output element by using the output pattern element variable as reference
name.
Internal vs. external trace models. The above presented trace model is internal
to the ATL transformation engine. It is the key for setting features of target
elements in a convenient way and for stopping the rule execution since a rule is
only executed for a match by the ATL execution engine, if this match, i.e., the set
of matched input elements, is not already covered by an existing trace link.
If for external traceability reasons, a persistent trace model is needed, e.g.,
to see the possible impact of source model changes on the target model, this
internal trace model (which is by default only transient) may be persisted as a
separate output model of the model transformation [40, 72].
Alternative notations. Until now, transformation rules have been defined in the
abstract syntax of the modeling language. An even higher readability may be
reached by using the concrete syntax of the modeling languages for defining the
transformation rules as shown for our graph transformation rule example in
Figure 8.6. However, only a few graph transformation tools provide this
capability. Furthermore, there are some approaches that use a condensed
graphical notation by merging the NACs, LHS, and RHS into one graph and
using some annotations for marking forbidden, preserved, deleted, or created
elements. Finally, some approaches use a textual concrete syntax to define the
graph transformation rules. We discuss protagonists of these different categories
in the end of this section.
Figure 8.5: Application of the graph transformation rule of Figure 8.4.
Figure 8.6: Graph transformation rule of Figure 8.4 shown in concrete syntax.
Tool Support. There are several Eclipse projects available which specifically
focus on providing graph transformation technologies for EMF. However,
besides this common goal, the different projects support diverse features for
implementing and executing graph transformations. Thus, the question of which
graph transformation tool to use has to be decided case-by-case depending on the
actual transformation problem.
Henshin11 is the successor of EMF Tiger and aims at introducing several
advanced features such as programmable graph transformations and several
analysis features such as model checking support. Furthermore, an integration
with AG12 is available which allows us to use several advanced graph
transformation techniques such as computing critical pairs between
transformation rules.
Fujaba13 is a protagonist of programmable graph transformation
approaches. In particular, story diagrams (comparable to UML activity diagrams)
are used to orchestrate graph transformation rules. Within the graph
transformation rules, Java is used for defining application conditions for the LHS
and assignments for the RHS.
e-Motions14 is an Eclipse plugin to graphically specify the behavior of
modeling languages by using graph transformation rules shown in the graphical
notation of the modeling languages. One unique feature of e-Motions is the
possibility to specify time-related attributes for rules, e.g., duration or
periodicity. Having defined the behavior of a modeling language in e-Motions,
the models can be simulated and analyzed by translating the models and the
model transformation to Maude15 which is a programming framework based on
rewriting logic.
ATL Refining. ATL Refining [68] adds a new execution mode to ATL
tailored for endogenous in-place transformations. The ATL Refining mode is
activated by simply substituting the from keyword with the refining keyword in
the header of an ATL transformation. In-place transformation rules are
syntactically written as standard out-place rules comprising an input pattern and
an output pattern. However, the execution of the rules is different. If an output
pattern element is already defined as an input pattern element (by sharing the
same variable name), the element is updated by the bindings, but not created.
Newly introduced output pattern elements (which have no counterpart in the
input pattern) are generated by the rule. For deleting elements, an output pattern
element can be annotated with a special keyword drop which means the element
will be deleted with all its containees, i.e., all elements directly or indirectly
contained by this element. To summarize, ATL Refining represents an in-place
transformation language using a textual syntax.
1http://www.eclipse.org/atl
2We show later how to safely avoid this restriction.
3Data Access Object
—http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
4To be precise, there is also a third kind of ATL rules, namely called rules which are very similar to lazy
rules.
5http://wiki.eclipse.org/M2M/QVT_Declarative_(QVTd)
6http://wiki.eclipse.org/M2M/Operational_QVT_Language_(QVTO)
7http://www.moflon.org
8http://www.cs.uni-paderborn.de/index.php?id=12842&L=1
9http://www.mdelab.de
10http://www.eclipse.org/epsilon/doc/etl
11http://www.eclipse.org/modeling/emft/henshin
12http://user.cs.tu-berlin.de/~gragra/agg
13http://www.fujaba.de
14http://atenea.lcc.uma.es/index.php/Main_Page/Resources/E-motions
15http://maude.cs.uiuc.edu
16http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Tools/#ATL_ant_tasks
17http://atenea.lcc.uma.es/index.php/Main_Page/Resources/Wires*
CHAPTER 9
Model-to-Text Transformations
Several concepts, languages, and tools have been proposed in the last decade to
automate the derivation of text from models by using Model-to-Text (M2T)
transformations. Such transformations have been used for automating several
software engineering tasks such as the generation of documentation, task lists,
etc.
Of course, the killer application of M2T transformations is code generation.
Actually, the main goal of model-driven software engineering is at the end of the
day to get a running system out of its models. Current execution platforms are
mostly code based—with a few exceptions which allow for a direct
interpretation of models (cf. discussion in Chapter 3). Thus, M2T
transformations are mostly concerned with code generation to achieve the
transition from the model level to the code level. Please note that not only the
code representing the system to develop may be derived from the models, but
also other code-related artifacts such as test cases, deployment scripts, etc. In
addition, formal code descriptions may be derived which allows us to analyze
different properties of a system (cf. Section 10.7). This is one of the major
benefits of using models—they may be used constructively to derive the system
as well as analytically to better explore or verify the properties of systems. M2T
transformations are currently the bridge to execution platforms and analysis
tools.
In this chapter, we start with the basics of model-based code generation
using M2T transformations, discuss different approaches to implement M2T
transformations, and finally, report on techniques for mastering the complexity
of code generators.
Figure 9.2: Code generation through programming languages: Java code that generates Java code.
2. Produce code: Collect the model information needed for generating the
code by using the model API to process the models. Typically, the object
graph is traversed starting from the root element of a model down to its leaf
elements.
3. Write code: Code is, for instance, saved in String variables, and finally,
persisted to files via streams.
Code generation example. In the previous chapter, we have shown how sWML
models are translated into sMVCML models. The sMVCML models have to be
subsequently translated to code to end up with an executable Web application.
An excerpt of this M2T transformation is now used to show how code generators
are implemented. Figure 9.3 shows an exemplary translation of a sMVCML
class (please note that for sMVCML, the UML class diagram notation is reused)
of our running example (cf. left-hand side) into corresponding Java code (cf.
right-hand side). As can be seen in this figure, the translation is straightforward,
but sufficient to show the major concepts required to implement code generators.
The sMVCML class is translated into a Java class which implements the
Serializable interface, the sMCVML attribute into a private variable with
getter/setter methods for accessing/modifying the variable, and the sMVCML
operation into a Java method. However, concerning the latter, only the method
signature can be derived from the sMVCML model. The implementation of the
methods is postponed to the code level. Thus, a partial code generation approach
is used. A major requirement is to take care of manually added code within
automatically generated code to allow for an iterative model-driven development
process.
The Java program for producing the discussed Java code from the
sMVCML language is shown in Listing 9.1. For the first phase, namely loading
the models, the EMF API, providing classes for loading resources, in our case
the sMVCML models, into memory, is used. In phase two, all model elements
are queried from the input model, and subsequently, iterated. If the model
element is a class (cf. instanceof type check), a String variable named code is
initialized and further filled with Java statements as String values. In phase three,
a stream is defined to a Java file with the name of the processed class and the
value of the code variable is persisted to this file. Of course, more sophisticated
GPL-based code generators may be developed using design patterns such as the
Visitor pattern [27], but the drawbacks stated in the following also apply for such
solutions.
// generate Attributes:
Iterator <Attribute > attIter = cl.getAtts(); ... code += ...
// generate Methods:
Iterator <Operation > opIter = cl.getOps(); ... code += ...
code += "}";
The advantages of this approach are that no additional programming skills are
needed. It is sufficient to know the programming language chosen to develop the
generator and to have familiarity with the model API. Furthermore, no additional
tools are needed, neither for the design time nor for the runtime. However,
following such an approach has also several drawbacks.
• Intermingled static/dynamic code: There is no separation of static code,
i.e., code that is generated in exactly the same way for every model element,
e.g., the package definition, the imports, etc., and dynamic code which is
derived from model information, e.g., class name, variable name.
• Non-graspable output structure: The structure of the output is not easily
graspable in the code generator specification. The problem is that the
produced code is embedded into the producing code. Thus, the control
structure of the code generator is explicit, but not the output format. This
problem is also manifested in other GPL-based generator approaches such
as in Java Servlets1 for producing HTML code by statements embedded in
the producing code.
• Missing declarative query language: There is no declarative query
language for accessing model information available. Thus, many iterators,
loops, and conditions as well as type casts unnecessarily lead to a huge
amount of code. Also, be aware that knowledge of the generated model API
is required. For example, to access features of model elements, getter
methods have to be used instead of querying the feature values just by using
the feature names defined in the metamodels.
• Missing reusable base functionality: Code has to be developed for reading
input models and persisting output code again and again for each code
generator.
To eliminate the mentioned disadvantages, DSLs have been developed for
generating text from models. This has also led to an OMG standard called MOF
Model to Text Transformation Language2 (MOFM2T). In the following section,
we show how the Java-based code generator may be re-implemented in a
dedicated M2T transformation language and discuss the benefits of such an
approach.
• XSLT: The XMI serializations of the models may be processed with XSLT,5
which is the W3C standard for transforming XML documents into arbitrary
text documents. However, in this case, the code generation scripts have to be
implemented based on the XMI serialization which requires some additional
knowledge on how models are actually encoded as XML files. Thus,
approaches directly operating on the model level are more favorable.
• JET: The Java Emitter Template (JET) project6 was one of the first
approaches for developing code generation for EMF-based models. But JET
is not limited to EMF-based models. In general, with JET, every Java-based
object is transformable to text. JET provides a JSP-like syntax tailored to
writing templates for M2T transformations. As for JSP, arbitrary Java
expressions may be embedded in JET templates. Furthermore, JET
templates are transformed to pure Java code for execution purposes.
However, there is no dedicated query language for models available in JET.
import java.io.Serializable;
[/file]
[/template]
In the javaMethod template, a protected area is used to define the space for
including the implementation of the operations. The produced output for this
template is shown in Listing 9.3. Please note that in the first generator run, the
protected area is created including only the standard comment and a default
return value as given in the template as a placeholder for the actual method
implementation. In all subsequent generator runs, this space is not changed
again, which means that the user can implement the method and the manually
added code is not lost in later generator runs.
This approach seems beneficial at a first sight: (i) reuse of the textual
concrete syntax definition ensures producing valid textual artifacts; (ii) having
an explicit metamodel for the text-based language allows us to better reason
about the language concepts and the mappings from the modeling language to
the text-based language; (iii) transformation definitions may be validated based
on the metamodels; (iv) output models representing the text-based artifacts can
be validated w.r.t. the target metamodel; and (v) changes in the concrete syntax
of the target language are independent of the transformation between the two
languages, thus, no additional maintenance of code generators is necessary.
However, there are also current limitations of this approach. Most of the
currently available metamodels for programming languages lack TCS
definitions, or even more aggravated, no metamodels exist for the languages or
they are not completely specified. Another drawback may be that the text-based
languages are only known by their TCS. Thus, reasoning on the language
concepts on the abstract syntax level may take some learning time, which is not
necessary when working with code generation templates. The abstraction from
reference code to transformation definitions is not supported in this approach by
just copying the code and substituting some parts of it with meta-markers as is
possible with M2T transformations. Furthermore, some features needed for
partial code generation scenarios are not covered, such as protected areas.
Finally, for a code generator, only a restricted part of the target language may be
needed, which is much easier to implement with an M2T transformation
language without reasoning on the complete language definition of the target
language.
To summarize, although there are some benefits in reducing an M2T
transformation to an M2M transformation, from a pragmatic viewpoint, it seems
easier to start with building a code generator by employing M2T transformation
languages—especially when no metamodel and TCS definitions for the target
language exists. Thus, the M2M/TCS approach for code generation should be
only considered when the target language is already supported by a metamodel
and a TCS and a full code generation approach is followed.
1http://www.oracle.com/technetwork/java/index-jsp-135475.html
2http://www.omg.org/spec/MOFM2T
3Please note that templates for code generation are different from templates in programming languages,
e.g., in C++, which allow for datatype independent programming.
4http://java.sun.com/products/jsp/reference/api/index.html
5http://www.w3.org/TR/xslt20/
6http://www.eclipse.org/modeling/m2t/?project=jet#jet
7http://www.eclipse.org/xtend
8http://www.eclipse.org/gmt/mofscript
9http://www.acceleo.org/
CHAPTER 10
Managing Models
This is the (simplified) XMI file generated for the UML example model when
using the MDT/UML2 Eclipse project2:
<packagedElement xmi:type="uml:Class" xmi:id="_c001" name="Employee">
<ownedAttribute xmi:id="_a001" name="name"/>
</packagedElement>
<packagedElement xmi:type="uml:PrimitiveType" xmi:id="_t001" name="String"/>
<packagedElement xmi:type="uml:Class" xmi:id="_c002" name="Department">
<ownedAttribute xmi:id="_a002" name="name" type="_t001"/>
</packagedElement>
<packagedElement xmi:type="uml:Association" xmi:id="_as001" name="WorksIn"
memberEnd="_e001 _e002">
<ownedEnd xmi:id="_e001" type="_c002" association="_as001"/>
<ownedEnd xmi:id="_e002" name="" type="_c001" association="_as001">
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="un001" value="*"/>
</ownedEnd>
</packagedElement>
and this is the (simplified) one produced by the open source ArgoUML tool,
which is not even conformant to the XMI syntax:
<UML:Class xmi.id ='_c001'
name ='Employee' visibility ='public' isSpecification ='false' isRoot ='false'
isLeaf ='false' isAbstract ='false' isActive ='false'>
<UML:Classifier.feature>
<UML:Attribute xmi.id ='_a001'
name ='name' visibility ='public' isSpecification ='false'
ownerScope ='instance' changeability ='changeable' targetScope ='instance'>
<UML:StructuralFeature.multiplicity>
<UML:Multiplicity xmi.id ='_m001'>
<UML:Multiplicity.range>
<UML:MultiplicityRange xmi.id ='_mr001'
lower ='1' upper ='1'/>
</UML:Multiplicity.range>
</UML:Multiplicity>
</UML:StructuralFeature.multiplicity>
<UML:StructuralFeature.type>
<UML:Class xmi.idref ='_st001'/>
</UML:StructuralFeature.type>
</UML:Attribute>
</UML:Classifier.feature>
</UML:Class>
<UML:Class xmi.id ='_c002'
name ='Department' visibility ='public' isSpecification ='false' isRoot ='false'
isLeaf ='false' isAbstract ='false' isActive ='false'>
... as before for the name attribute .....
</UML:Class>
<UML:Association xmi.id ='_as001'
name ='WorksIn' isSpecification ='false' isRoot ='false' isLeaf ='false'
isAbstract ='false'>
<UML:Association.connection>
<UML:AssociationEnd xmi.id ='_ae001'
visibility ='public' isSpecification ='false' isNavigable ='true'
ordering ='unordered' aggregation ='none' targetScope ='instance'
changeability ='changeable'>
<UML:AssociationEnd.multiplicity>
<UML:Multiplicity xmi.id ='_m001'>
<UML:Multiplicity.range>
<UML:MultiplicityRange xmi.id ='_mr001'
lower ='1' upper ='-1'/>
</UML:Multiplicity.range>
</UML:Multiplicity>
</UML:AssociationEnd.multiplicity>
<UML:AssociationEnd.participant>
<UML:Class xmi.idref ='_c001'/>
</UML:AssociationEnd.participant>
</UML:AssociationEnd>
... same for the second association end ...
</UML:Association.connection>
</UML:Association>
• CDO: The CDO (Connected Data Objects) Model Repository5 was created
with this goal in mind. CDO is a run-time persistence framework optimized
for scalable query and transactional support for large object graphs. As
back-end, CDO supports different strategies (object, NoSQL, and relational
databases) though its main focus is on the latter. For relational databases,
CDO relies on Teneo,6 a Model-Relational mapping and runtime database
persistence solution for EMF that can also be used as a stand-alone tool.
• NeoEMF: A NoSQL multi-backend framework for persisting and querying
large models. It recognizes that there is no perfect backend for model
storage and therefore facilitates the addition of custom backends for specific
needs. By default, it includes a graph-based backend (compatible with
Blueprints databases, especially Neo4J7) and a MapDB backend. Other
NoSQL prototype tools are Morsa8 and MongoEMF,9 both using
MongoDB as backend.
For EMF models several model comparison tools and frameworks exist.
• Edapt18 provides support for the evolution of Ecore metamodels and the
automatic migration of models to the new metamodel version by providing
standard migration strategies.
• Epsilon Flock19 is a model migration language built atop the Epsilon family
of languages, for automatically updating models in response to metamodel
changes.
• Any M2M transformation language may be used to specify migration
paths for models for dealing with co-evolution.
Behind the scenes, MoScript does a type check between the metamodels of
the models to be transformed and checks the compatibility between the
metamodels and the transformations by querying the megamodel. In the same
way MoScript determines which transformation engine should execute the
transformation. Finally, MoScript sends the models, metamodels, and
transformations to the transformation engine for execution. The resulting models
may be persisted in the model repository, inspected, or even transformed again
with a chained MoScript script.
Even if the model is small and has no OCL constraints, it turns out that it is
impossible to instantiate the model in a way that all cardinality constraints in the
associations become satisfied at the same time (this is known as the satisfiability
problem and many more advanced correctness properties, like redundancy, are
defined based on this one). Therefore, the model is useless since users will never
be able to use it to store any consistent information. The error in this model is
that the EnrollsIn association forces the system to have at least 20 students per
course while Likes states that the number of students per course must be exactly
5.
For this example, and given that the problem lies only the cardinality
constraints, a verification tool could easily detect the errors and provide adequate
feedback to the user, but unfortunately the problem of checking the correctness
of an arbitrary model (including any combination of modeling constructs plus
integrity constraints expressed in an expressive language like OCL) is a very
complex one (in fact, it is not even decidable in general, meaning that it is not
possible to create an algorithm that decides whether an arbitrary model is correct
or not). This explains why so far we do not have any available verification tool
that can be easily integrated with state-of-the-art modeling tools. Existing
verification tools require designer interaction, restricting the possible elements to
be used in the models, and deep knowledge of formal methods or extensive
manual model annotations which seriously impair its usability in practice.
To avoid these problems, a new generation of verification tools follows a
more pragmatic approach where, instead of trying to find a perfect answer, the
goal is to give an answer (with a certain degree of confidence) in a reasonable
amount of time. An example of such tools is EMFtoCSP,23 a tool that checks
UML and EMF models by transforming them transparently to a constraint
satisfaction problem [70] that is then sent to a constraints solver to evaluate the
satisfiability of the model.
The relevant correctness properties for each model depend on the type of
the model. For static models (such as UML class diagrams) typical properties
involve the satisfiability property mentioned before (i.e., it must be possible to
create a valid instantiation of the model) and absence of redundancies. For
dynamic models, useful properties involve the absence of deadlocks and infinite
recursion as well as the applicability and executability of operations.
1http://www.omg.org/spec/XMI/2.4.1
2http://wiki.eclipse.org/MDT-UML2
3http://www.omgwiki.org/model-interchange
4http://www.omg.org/spec/DD
5http://wiki.eclipse.org/CDO
6http://wiki.eclipse.org/Teneo
7http://neo4j.com
8http://modelum.es/trac/morsa
9https://github.com/BryanHunt/mongo-emf/wiki
10https://github.com/markus1978/emf-fragments
11https://www.eclipse.org/incquery
12http://www.eclipse.org/emf/compare
13http://pi.informatik.uni-siegen.de/sidiff
14http://www.eclipse.org/epsilon/doc/ecl
15http://www.eclipse.org/emfstore
16http://www.modelversioning.org
17http://www.eclipse.org/epsilon/doc/eml
18http://wiki.eclipse.org/Edapt
19http://www.eclipse.org/epsilon/doc/flock
20http://gemoc.org
21http://wiki.eclipse.org/AM3
22http://wiki.eclipse.org/MoScript
23https://github.com/SOM-Research/EMFtoCSP
24http://useocl.sourceforge.net/w/index.php/Main_Page
25http://agilemodeling.com/essays/modelReviews.htm
26http://eclipse.org/egerrit
27Here we focus on projects under the umbrella of the Eclipse Modeling
Framework. Several commercial tools offer proprietary solutions as
well.
28http://chico.inf-cr.uclm.es/jgallardo/space.html
29http://wiki.eclipse.org/Dawn
30https://github.com/SOM-Research/collaboro
31http://emf-rest.com
CHAPTER 11
Summary
[55] Object Management Group (OMG). MDA guide revision 2.0, 2014. http://www.omg.org/cgi-
bin/doc?ormsc/14-06-01 43
[56] Object Management Group (OMG). Meta object facility, version 2.0, 2006.
http://www.omg.org/spec/MOF/2.0/PDF 89
[57] Object Management Group (OMG). Unified modelling language superstructure specification, version
2.1.2, 2007. http://www.omg.org/spec/UML/2.1.2/Superstructure/PDF 102
[58] Klaus Pohl, Günter Böckle, and Frank J. van der Linden. Software Product Line Engineering:
Foundations, Principles, and Techniques, Springer, 2005. DOI: 10.1007/3-540-28901-1. 59
[59] Louis M. Rose, Markus Herrmannsdoerfer, James R. Williams, Dimitrios S. Kolovos, Kelly Garcés,
Richard F. Paige, and Fiona A. C. Polack. A Comparison of Model Migration Tools. In Dorina C.
Petriu, Nicolas Rouquette, and Øystein Haugen, Eds., Proc. of the 13th International Conference on
Model Driven Engineering Languages and Systems (MODELS’10), volume 6394 of Lecture Notes in
Computer Science, pages 61–75, Springer, 2010. DOI: 10.1007/978-3-642-16145-2. 166
[60] Andy Schürr. Specification of graph translators with triple graph grammars. In Proc. of the 20th
International Workshop on Graph-Theoretic Concepts in Computer Science (WG’94), volume 903 of
Lecture Notes in Computer Science, pages 151–163, Springer, 1994. DOI: 10.1007/3-540-59071-4_45.
131
[61] Shane Sendall and Wojtek Kozaczynski. Model transformation: The heart and soul of model-driven
software development. IEEE Software, 20(5):42–45, 2003. DOI: 10.1109/ms.2003.1231150. 123
[62] Thomas Stahl, Markus Voelter, and Krzysztof Czarnecki. Model-Driven Software Development:
Technology, Engineering, Management, John Wiley & Sons, 2006. 92
[63] Friedrich Steimann and Thomas Kühne. Coding for the code. Queue, 3:44–51, 2005. DOI:
10.1145/1113322.1113336. 23
[64] David Steinberg, Frank Budinsky, Marcelo Paternostro, and Ed Merks. EMF: Eclipse Modeling
Framework 2.0, 2nd ed., Addison-Wesley Professional, 2009. 143
[65] Perdita Stevens. A Landscape of Bidirectional Model Transformations. In Proc. of the International
Summer School on Generative and Transformational Techniques in Software Engineering II
(GTTSE’07), volume 5235 of Lecture Notes in Computer Science, pages 408–424, Springer, 2007.
DOI: 10.1007/978-3-540-88643-3_10. 139
[66] Eugene Syriani and Hans Vangheluwe. De-/re-constructing model transformation languages.
ECEASST, 29:1-14, 2010. DOI: 10.14279/tuj.eceasst.29.407. 136
[67] Massimo Tisi, Frédéric Jouault, Piero Fraternali, Stefano Ceri, and Jean Bézivin. On the use of higher-
order model transformations. In Proc. of the 5th European Conference on Model Driven Architecture
—Foundations and Applications (ECMDA-FA’09), volume 5562 of Lecture Notes in Computer
Science, pages 18–33, Springer, 2009. DOI: 10.1007/978-3-642-02674-4_3. 138
[68] Massimo Tisi, Salvador Martínez, Frédéric Jouault, and Jordi Cabot. Refining models with rule-based
model transformations. Research Report RR-7582, INRIA, 2011. 137, 139
[69] Albert Tort, Antoni Olivé, and Maria-Ribera Sancho. An approach to test-driven development of
conceptual schemas. Data & Knowledge Engineering, 70(12):1088–1111, 2011. DOI:
10.1016/j.datak.2011.07.006. 59
[70] Edward Tsang. Foundations of Constraint Satisfaction, Academic Press, 1993. DOI: 10.1016/c2013-0-
07627-x. 170
[71] Markus Völter. A catalog of patterns for program generation. In Kevlin Henney and Dietmar Schütz,
editors, Proc. of the 8th European Conference on Pattern Languages of Programs (EuroPLoP’03),
pages 285–320, 2003. 28
[72] Andrés Yie and Dennis Wagelaar. Advanced traceability for ATL. In Proc. of the 1st International
Workshop on Model Transformation with ATL (MtATL 2009), 2009. 131
Authors’ Biographies
MARCO BRAMBILLA
JORDI CABOT
MANUEL WIMMER
Manuel Wimmer is a professor in the Business Informatics Group (BIG) at TU
Wien (Austria). He has been a visiting professor at TU München (Germany) and
at the Philipps-University Marburg (Germany) as well as a research associate at
the University of Málaga (Spain). He is involved in several research projects in
the area of model-driven engineering, model versioning, and model
transformation which resulted in numerous scientific publications in
international journals and conferences. Since 2005, he has taught the model-
driven engineering course (about 200 students each year) at TU Wien and holds
several industry seminars on how to efficiently apply model-driven engineering
in practice.
Home page: http://www.big.tuwien.ac.at/staff/mwimmer
Index
The index that appeared in the print version of this title was intentionally removed from the eBook. Please
use the search function on your eReading device for terms of interest. For your reference, the terms that
appear in the print index are listed below
abstract syntax
Abstract Syntax Tree Metamodel
abstraction
Acceleo
Action Language for fUML
activity diagram
ADM
adoption
adoption life cycle
aggregation
agile development
Agile Manifesto
Agile Modeling
Alf
AM
application domain
application scenario
architecture
Architecture-Driven Modernization
ASTM
ATL
ATLAS Transformation Language
automation
base metaclass
batch transformation
behavior diagram
bi-directional transformation
blueprint
BPMN
business process
Business Process Model and Notation
cardinality constraints
CDO
CIM
class diagram
classification
code generation
code generator
collaboration diagram
collaborative modeling
communication diagram
complete code generation
component diagram
composite structure diagram
Computation-Independent Model
concept
conceptualization
concrete syntax
conformsTo relationship
Connected Data Objects
constraint
database
DDD
declarative DSL
denotational semantics
deployment diagram
descriptive model
design
development process
diagram
Diagram Interchange
domain engineering
domain model
Domain-Driven Design
Domain-Specific Language
Domain-Specific Modeling Language
drawing
drawing tool
DSL
dynamic diagram
dynamic model
EBNF
Eclipse
Eclipse Modeling Framework
Ecore
EMF
endogenous transformation
Enterprise Architecture
enterprise architecture
Epsilon
Epsilon Transformation Language
ETL
EuGENia
executable model
Executable UML
exogenous transformation
extensibility
extensional mapping
external DSL
extraction
extractor
eXtreme Programming
family of languages
feature model
feature-oriented software development
FOSD
Foundational Subset for Executable UML Models
fUML
GCS
GEF
General-Purpose Modeling Language
generalization
Git
Global Model Management
GMF
GMM
grammar
grammarware
graph grammar
graph transformation
Graphical Editing Framework
Graphical Modeling Framework
Graphiti
i*
icon
IFML
imperative DSL
in-place transformation
incremental transformation
injection
injector
intensional mapping
interaction diagram
Interaction Flow Modeling Language
interaction overview diagram
internal DSL
interoperability
interpreter
KDM
keyword
Knowledge Discovery Metamodel
lazy transformation
legacy system
levels of detail
M2M
M2T
mapping
MBE
MD*
MDA
MDD
MDE
MDRE
MDSE
Megamodel
meta
Meta Object Facility
meta-marker
meta-metamodel
meta-metamodeling
metamodel
metamodeling
metamodeling framework
metamodeling languages
metamodeling stack
methodology
model
model (re)generation
model comparison
model compiler
model differencing
model discovery
model evolution
model interpretation
model management
model mapping
model matching
model migration
model persistence
model quality
model repository
model review
model transformation
model understanding
model verification
model versioning
model weaving
model-based engineering
model-based testing
Model-Driven Architecture
Model-Driven Development
Model-Driven Interoperability
Model-Driven Reverse Engineering
Model-Driven Software Engineering
model-driven testing
Model-to-Model transformation
Model-to-Text (M2T) transformation
Model-to-Text transformation
Model-View-Controller pattern
modeling
modeling language suite
modeling tool
modelware
MOF
MOF Model to Text Transformation Language
MOFM2T
MVC
NoSQL
notation
package diagram
partial code generation
pattern-based design
PIM
platform
Platform-as-a-Service
Platform-Independent Model
Platform-Specific Model
prescriptive model
problem domain
problem space
process
process mining
program
projector
PSM
Query-View-Transformation
QVT
semantic mapping
semantics
sequence diagram
simple Web Modeling Language
Sirius
sketch
SMM
SoaML
software development automation
software factory
Software Measurement Metamodel
software modernization
software product line
software product line engineering
solution space
state machine diagram
statechart
static diagram
static models
stereotype
structure diagram
sWML
syntactic mapping
SysML
system
system specification
T2M
tagged value
TCS
TDD
technical space
template
template engine
Test-driven development
test-driven modeling
Text-to-Model transformation
TGG
timing diagram
TOGAF
tool
trace link
trace model
transformation
transformation chain
translational semantics
Triple Graph Grammars
UML
UML modeling tool
UML profile
uni-directional transformation
Unified Modeling Language
Unified Process
UP
use case diagram
variability modeling
vertical DSL
vertical transformation
VHDL
view
viewpoint
XMI
XML Metadata Interchange
XML Process Definition Language
XP
Xtext
Zachman