Model-Driven Development - From Frontend To Code
Model-Driven Development - From Frontend To Code
Model-Driven Development -
From Frontend to Code
mental work
of developers
several
Metametamodel
target
subdomains
software
design architecture
bounded area of
expertise partial
composable knowlege/interest
knowledge multiple
multi-step transform viewpoint
Domain
single-step compile Model semantics
Ontology
interpret
no precise/
roundtrip Domain
executable
Specific
Language
graphical
Metamodel
textual
transformed to executable
code.
• Optionally, the generated Model Metamodel
• Goals:
• We need an end-to-end tool chain that allows us to
build models, verify them and generate various artefacts
from them.
• All of this should happen in a homogeneous environment,
namely Eclipse.
• Challenges:
• Good Editors for your models
• Verifying the models as you build them
• Transforming/Modifying models
• Generating Code
• Integrating generated and non-generated code
machines in Java.
• Recipes help developers with the imple-
Session 2
10‘
mentation of the actions associated with states.
• The metamodel
is defined using
EMF.
• EMF provides
tree-based
editors to define
the metamodel.
• The metamodel
has its own
project called
oaw4.demo.gmf.
statemachine2
Overview
Pane
Tool
Palette
These rectangles
are to demo
decorations ☺ Model
Element
Properties
Constraints
Constraints II
Constraints III
Error message
in case
Expression is
Constraint false
ERROR or Expression
•
WARNING
Note the code completion and error highlighting ☺
Constraints IV
Constraints V
Code Generation
Code Generation II
Code Generation IV
Code Generation V
Namespace and
Extension Import • The blue text is
generated into
the target file.
Opens a
File
Name is a property
of the State-
Machine class
• The capitalized
words are
xPand keywords
Calls another
• Black text are
Iterates
over all template metamodel
the states
of the
properties
•
State-
Machine DEFINE...END-
Extension Call
DEFINE blocks
are called
Template
name Like methods in OO, templates.
templates are
associated with a
(meta)class • The whole thing
is called a
template file.
Code Generation VI
Extensions are
typically defined
for a metaclass
A number of
parameters are
passed in
We invoke the
same check file as
in the editor
Code is
automatically
beautified
Recipes I
a)
b)
c) d) e)
generated code non-generated code
Recipes II
Recipes III
Recipes can be
arranged
hierarchically
„Green“ ones
This is a can also be
failed check hidden Here you can see
additional
information about
the selected recipe
Recipes IV
Recipes V
Recipes VI
…and override a
suitable template
method
Model Transformations I
Model Transformation II
„create extensions“
guarantee that for
each set of
parameters the
identical result will
be returned.
Therefore
createShutDown()
will always return
the same element.
Model Transformation IV
• We need to ‘normalize’
composite states.
Textual Editor I
Textual Editor II
Rule names
will
Rule become the
name AST classes
States contain
a number of
entry actions,
transitions and
exit actions
Textual Editor IV
Textual Editor V
• The generated editor and it’s outline view
Literals
have
become
keywords
Constraints
are
evaluated
in real time
Tooling Versions
Summary
• THANK YOU.