w w w .ict.tu w ien.ac.at
IT
Vertiefung
Edin Arnautovic Institute of Computer Technology /99 Edin Arnautovic Wolfgang Radinger w w w .ict.tu w ien.ac.atModel
‐
Driven
Software
Development
MDSD Concepts
Metamodeling, MOF, Ecore
MDSD Process
Model Driven Generation
OMG Model Driven Architecture
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
MDSD Concepts
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.atWarum
modellieren
wir?
Modelle sind notwendig
• um Informationen verständlicher darzustellen
• um essentielle Systemaspekte aufzuzeigen
• zur Kommunikation (Projektmitglieder, Kunde)
• um komplexe Systeme darstellen zu können
Institute of
w w w .ict.tu w ien.ac.at
Models
in
Traditional
Engineering
As old as engineering
Traditional means of reducing engineering risk
Institute of
Computer Technology /99
from Brian Seltic
w w w .ict.tu w ien.ac.at
What
Engineers
Do
Before they build the real thing...
…they first build models…and then learn from them
Institute of
Computer Technology /99
from Brian Seltic
w w w .ict.tu w ien.ac.at
Models
Engineering model• A reduced representation of some system that is easier to understand than the actual system
How Models are Used• To detect errors and omissions and to determine key tradeoffs
in complex designs before committing full resources to
realization
−Through (formal) analysis and experimentation −Investigate and compare alternative solutions
Institute of
Computer Technology /99
g p
−Minimize engineering risk
To communicate with stakeholders• Clients, users, implementers, testers, documenters, etc.
To
drive
implementation
7 w w w .ict.tu w ien.ac.atModels
are
the
new
code
High Level
When the system evolves or a problem occurs, modify a model, or a mapping, not the code!
Assembly Code M hi C d Assembler Executable Models S C d Model Compiler Assembly Code Source Code Compiler High Level Language Source Code Institute of Computer Technology /99 Machine Code 1960’s None Source Code 2000’s Software Platform Assembly Code 1980’s Hardware Platform
w w w .ict.tu w ien.ac.at
What
is
MDSD?
MDSD = Model‐DrivenSoftware Development
• different than model‐based
Models are first‐class objects
Based around domain‐driven metamodeling
It is also: development of infrastructureto develop software
(software factories) Institute of Computer Technology /99 (software factories) w w w .ict.tu w ien.ac.at
Model
based
vs.
model
driven
Institute of Computer Technology 10/99 w w w .ict.tu w ien.ac.at
Reasons
for
using
MDSD
• You want to provide a way for your domain‐experts to formally specify their
knowledge, and to provide a way for your technology people to define how this is implemented
(using model transformations).
• You might want to provide different implementations (i.e. more concrete models)
for the same model, perhaps because you want to run it on different platforms (.NET, Java, CORBA).
• You may want to capture knowledge about the domain, the technology, and their mapping in a clear, unclutteredformat.
• In general, you don’t want to bother with implementation details when specifying your functionality.
Institute of
Computer Technology /99
• MDSD results in a fan‐out, i.e. one set of models can be the source for transformations to several targets.
• Another reason for using MDSD: You are working in the context of product lines
and software system familiesand need to develop domain‐specific assets.
- 11 -© 2 0 0 4 M a rk u s V ö l t e r w w w .ict.tu w ien.ac.at
Advantages
of
MDSD
Better integration of domain experts
Faster software changes
Validation of software‐under‐construction
Better realization of the software architecture
Enhanced portability to other platforms
More efficient for product line development
Institute of
Computer Technology /99
w w w .ict.tu w ien.ac.at
Disadvantages
of
MDSD
Higher overhead for one‐of‐a‐kind system
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Concepts
Modelsexpressing the application functionality based on
domain specific languages
Domain specific languages, usually expressed by metamodels Platformscontains common middleware (e.g. CORBA, J2EE, or
.NET) and domain specific frameworks
Transformationsto map models to platforms
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
How
MDSD
works
Developer develops model(s) based on certain metamodel(s), expressed using a DSL. Model Model Model Metamodel Using code generation templates, the model is transformed to executable code.
• Alternative: Interpretation
Optionally, the generated code is
mergedwith manually written code.
Transformer Tranformation Rules Model Metamodel opt ional, can b e r e peated Institute of Computer Technology /99 g y
One or more model‐to‐model
transformation stepsmay precede
code generation. - 15 -Transformer Code Generation Templates Generated Code Manually Written Code optional © 2 0 0 4 M a rk u s V ö l t e r w w w .ict.tu w ien.ac.at
Domain
Driven
Development
Domain Driven Development is about making softwaredevelopment more domain‐related as opposed to
computing related. It is also about making software
development in a certain domain more efficient.
Domain Concepts Domain Concepts
mental work of developers Institute of Computer Technology - 16-/99 Software Technology Concepts Software Technology Concepts © 2 0 0 4 M a rk u s V ö l t e r
w w w .ict.tu w ien.ac.at
What
is
a
„Domain“
A definitioncould be:A domain is a bounded area of knowledge or interest.
Examples (from the world of Software) include:• eBanking • Embedded Software • Web‐Based eBusiness Applications Institute of Computer Technology /99 pp • Control Software for 4‐Cylinder Diesel Engines • Astronomical Image Processing Software
Domains can have varios „scopes“ as well as various„flavours“. - 17 -© 2 0 0 4 M a rk u s V ö l t e r w w w .ict.tu w ien.ac.at
„Kinds“
of
Domains
In the context of software development it is also useful to distinguish (at least) two kinds of domains:• Functional Domainsrepresentp the business/professional/p issues;; −Banking −Human resource management −Insurance −Engine Controllers −Astronomical Telescope Control Institute of Computer Technology /99
• Technical Domains adress key technical issues for software development
−Distribution, Failover and Load‐Balancin −Persistence and Transactions −GUI Design −Concurreny and Realtime - 18 -© 2 0 0 4 M a rk u s V ö l t e r w w w .ict.tu w ien.ac.at
Domain
Specific
Language
Defines the semantic of the model
The notation (concrete syntax)of the DSL can be textual or
graphical
More important: The DSL’s abstract syntax, better known as
metamodel
Metamodeldefines the model elementsfor domain modeling
The DSL’s semanticsare used to transformthe DSL to general‐
Institute of Computer Technology /99 purpose languages w w w .ict.tu w ien.ac.at
Metamodeling /
Meta Object Facility
Institute of
w w w .ict.tu w ien.ac.at
Klasse
vs.
Objekte
Klassen stellen Konzepte dar. Bei OOP werden sie in einer OO‐
Programmiersprache implementiert
• Objekte dieser Klasse existieren zur Ausführungszeit, um das Verhalten
und Wissen des Systems bereitzustellen.
Klasse Objekt Auto Kennzeichen :Auto W 12345 A :Auto W 1111 AB Institute of Computer Technology /99 :Auto W 2222 XY :Auto S 1234 XY w w w .ict.tu w ien.ac.at
Objektdiagramme
Statische Objektdiagramme sind manchmal hilfreich
• Bei der Erläuterung des Klassendiagramms
• Bei Schwierigkeiten mit der Klassifikation
• Zur Untersuchung der Multiplizität
• Zur Darstellung von Vorher‐und Nachher‐Zuständen
myFlug:Flug Abflugort = VIE Zielort =LAX Institute of Computer Technology /99 leg_1:Leg Abflugort = VIE Zielort =FRA leg_2:Leg Abflugort = FRA Zielort =LAX w w w .ict.tu w ien.ac.at
Aggregation
Die Aggregation bestimmt Ganzes Teil Beziehungen.
Besitzverhältnis
• Die Klasse die das Ganze darstellt besitzt die Klasse die die Teile
modelliert, und steuert den Zugriff.
Lebensspanne
• Das Ganze erstellt und löscht die Teile.
Zugriffsmöglichkeiten
Institute of
Computer Technology /99
Zugriffsmöglichkeiten
• Auf die Teile wird über das Ganze zugegriffen.
Weiterreichung
• Einige Operationen auf der Ebene des Ganzen bewirken die
gleichen Operationen bei den Teilen.
w w w .ict.tu w ien.ac.at
Beispiel:
Aggregation
M hl it {or} MahlzeitSuppe Salat Hauptgericht Dessert
1 1 1 1
Institute of
w w w .ict.tu w ien.ac.at
Multiplizitäten
Bereiche • [min – max] z.B. [1..10] • * Æbeliebig z.B. [0..*] genau 1: 1 ≥0: * oder 0..* 0 ∨1: 0..1 fixe Anzahl (z B 3): 3 Institute of Computer Technology /99 fixe Anzahl (z.B. 3): 3 Bereich (z.B. ≥3): 3..* Bereich (z.B. 3-6): 3..6 Aufzählung : 3,6,7,8,9 oder 3, 6..9Folie Hitz & Kappel, UML @ Work
w w w .ict.tu w ien.ac.at
Komposition
Die Komposition ist eine starke Aggregation.
Drückt eine physikalische Inklusion der Teile im Ganzen aus.
Teile und Ganzen bilden eine Einheit
Kaffeetisch 1 Institute of Computer Technology /99 Tischplatte Tischbein 1 4 1 w w w .ict.tu w ien.ac.at
Metamodel
Meta‐: means about
Metamodel: describes the possible structure of models
conforming to the metamodel
Real-world
elements model elements metamodel elements
Domain Model Metamodel
Institute of Computer Technology /99 elements elements describes describes w w w .ict.tu w ien.ac.at
Metamodeling
1
Institute of Computer Technology 28/99 ©w w w .ict.tu w ien.ac.at
Metamodeling
2
Metamodeling allows for the modeling of modeling languages
• Analogy to EBNF for programming languages. E.g. C: −<function-definition>::= <function-heading> <function-body> −<function-heading>::=
<return-type> <function-name>'('<formal-parameter-phrase> −if ( <expression> ) <statement 1> else <statement 2>
Metamodeling allows thedefinition of tailored ordomain‐
specific modeling languages
Institute of
Computer Technology /99
p g g g
A metamodel definesthe abstract syntaxof a modeling
language
Model : Metamodel = Instance : Class
w w w .ict.tu w ien.ac.at
Use
case
– model
Institute of Computer Technology 30/99 w w w .ict.tu w ien.ac.at
Use
case
– metamodel
Institute of
Computer Technology Nico Suchold openArchitectureWare/99
w w w .ict.tu w ien.ac.at
Example
1:
Model
and
Metamodel
interface Sensor { operation start():void; operation stop():void; operation measure():float; operation measure():float; } interface Controller { operation reportProblem(Sensor s, String errorDesc ):void; } {ordered} Interface Operation Parameter Institute of Computer Technology - 32-/99 * name : String type : String name : String type : String type : String Exception * * © 2 0 0 4 M a rk u s V ö l t e r
w w w .ict.tu w ien.ac.at
Example:
Architecture
‐
centric
Metamodel
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Domain
‐
centric
Model
Institute of Computer Technology 34/99 w w w .ict.tu w ien.ac.at
Domain
‐
centric
Metamodel
Institute of Computer Technology 35/99 w w w .ict.tu w ien.ac.at Institute of Computer Technology 36/99 ©
w w w .ict.tu w ien.ac.at
Meta‐Object Facility
(
MOF
)
Object Management Group
Institute of
Computer Technology /99
Object Management Group
3 w w w .ict.tu w ien.ac.at
MOF
– Meta
Object
Facility
Is an object‐oriented modeling language Uses UML syntax
Used to formally define UML by the OMG
UML 2.0 was also an aiming a redefining the UML formally
based on an extended MOF
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
MOF
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.atObject
Management
Group
(OMG
)
OMG’s
Mission
Since
1989
Æ
Develop
an
architecture,
using
object technology,
f
di t ib t d
li ti
i t
ti
t i
for
distributed
application
integration,
guaranteeing:
• reusability of components
• interoperability & portability
• basis in commercially available software
Specifications
freely
available
Institute of
Computer Technology /99
Implementations
exist
Member
‐
controlled
not
‐
for
‐
profit
w w w .ict.tu w ien.ac.at
OMG’s
Major
Successes
Common
Object
Request
Broker
Architecture
• CORBA® remains the only language‐and platform‐neutral interoperability
standard
Unified Modeling Language• UMLTMremains the world’s only standardized modeling language
Common Warehouse Metamodel• CWMTM, the integration of the last two data warehousing initiatives
Meta‐Object FacilityInstitute of
Computer Technology /99
Meta Object Facility • MOFTM, the repository standard
XML Metadata Interchange• XMITM, the XML‐UML standard
© Richard Mark Soley
w w w .ict.tu w ien.ac.at
OMG’s
Metalevels
describes instance of MOF
(Meta-Object ili ) M1: Model M2: Metamodel M3: Meta-metamodel instance of describes instance of describes Facility) Institute of Computer Technology /99 M0: Instances M1: Model instance of describes w w w .ict.tu w ien.ac.at
MOF
Example
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.atThe
relationship
between
metamodel and
model
Institute of
w w w .ict.tu w ien.ac.at
Class
Diagram
Ù
Object
Diagram
Level n Institute of Computer Technology /99 Level n + 1 w w w .ict.tu w ien.ac.at
ECLIPSE MODELING FRAMEWORK
Institute of
Computer Technology /99
ECLIPSE MODELING FRAMEWORK
4 w w w .ict.tu w ien.ac.at
Eclipse
Modeling
in
a
Nutshell
Eclipse Modeling is the umbrella project for all things modeling that happen on the Eclipse platform:
The Eclipse Modeling Project focuses on the evolution and promotion
of model‐based development technologies within the Eclipse community
by providing a unified set of modeling frameworks, tooling, and standards
implementations.
Eclipse Modeling is not formally related to OMG, but implements
several of their standards
Institute of
Computer Technology /99
several of their standards.
It is fair to say that many leading edge modeling tools are
hosted/developed at Eclipse Modeling.
Everything Open Source under the Eclipse Public License
© 2 0 0 4 Markus Voelter, Bernd Kolb, Peter Friese
w w w .ict.tu w ien.ac.at
EMP
Core:
EMF
The Eclipse Modeling Framework (EMF) serves as the
foundation: It provides the Ecore Metametamodel and
frameworks and tools around it for tasks such as
frameworks and tools around it for tasks such as
• Editing • Transactions • Validation • Query i ib i / i ( j ) Institute of Computer Technology /99
w w w .ict.tu w ien.ac.at
EMF (2)
Modeling framework and code generation facility for building
tools and other applications
• Model specification described in XMI
• Models can be specified using annotated Java, XML documents and
modeling tools
• Foundation for interoperability with other EMF‐based tools and
applications
Provides tools and runtime support for models
Institute of
Computer Technology /99
pp
• Set of Java classes for the model
• Set of adapter classes for viewing editing of the model
• Basic editor 49 w w w .ict.tu w ien.ac.at
EMF (3)
Meta model (Ecore) for describing models
Reflective API
EObject extends Notifier Æmonitor all changes to the object's
data Institute of Computer Technology 50/99 w w w .ict.tu w ien.ac.at Institute of Computer Technology 51/99 w w w .ict.tu w ien.ac.at
Domain
Specific
Language
Defines the semantic of the model
The notation (concrete syntax)of the DSL can be textual of
graphical
More important: The DSL’s abstract syntax, better known as
metamodel
Metamodeldefines the model elementsfor domain modeling
The DSL’s semanticsare used to transformthe DSL to general‐
Institute of
Computer Technology /99
w w w .ict.tu w ien.ac.at
Definition
of
Our
Own
DSL
Two approaches for defining a DSL:
• Alternative 1: Start from scratchbased on a predefined meta‐metamodel
(e.g. MOF)
• Alternative 2:Use an available metamodel(e.g. UML metamodel) and
extend it Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Alternative
1
Example: Metamodel for “Feature Modeling” based on MOF
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Alternative
1
– Instance
of
the
Metamodel
UML Notation:
Feature Model Notation:
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Alternative
2
Extending forexample the UML
metamodel: metamodel:
It can be used in the following ways:
Institute of
w w w .ict.tu w ien.ac.at
Alternative
2
– UML
Profiles
formally use the meta‐metamodel to extend the UML
metamodel
Since there aren’t many MOF‐based tools, UML profiles can be
used
Metamodel elementsmap to <<stereotypes>>
Metamodel attributesmap to {tagged values}
Metamodel constraintsmap to modeling constraints/rules
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Example
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.atUML
2.x
Profile
Metamodel
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Enterprise
JavaBeans
Component Architecture for Enterprise Applications
Beans:
• Entity
• Session (Stateless/Stateful)
• Message
Remote and Home Access through Interfaces
Institute of
w w w .ict.tu w ien.ac.at
Example
EJB
Profile
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Kinds
of
Metamodels
Architecture‐centric MDSD• Represents the concept of the technical platform
• Simpler transformations
• Domain concepts can be added iteratively
• Used if no sophisticated domain‐specific metamodel available
Domain‐centric MDSD
• Useful for product line development in single domain
Institute of Computer Technology /99 p p g w w w .ict.tu w ien.ac.at
Example:
Architecture
‐
centric
Metamodel
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Domain
‐
centric
Metamodel
Institute of
w w w .ict.tu w ien.ac.at
Multiple
Technical
Domains
One DSL is usually not suitable to describe all aspects of a
complex system (e.g. persistence, GUI,…)
Define multiple domains with their metamodel
Connect them by small number of gateway meta classes
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Domain
‐
centric
Metamodel
(2)
Institute of Computer Technology 66/99 w w w .ict.tu w ien.ac.at
How
do
I
come
up
with
a
good
metamodel?
Incrementally!
Based onBased on experienceexperiencefrom previous projects and by mining“from previous projects, and by „mining domain experts.
A very good idea is to start with a (typically) very well known domain: the target software architecture (platform)
ÆArchitecture‐Centric DSLs Æsee below Cascading
Institute of
Computer Technology /99
Æsee below, Cascading
- 67 -© 2 0 0 4 M a rk u s V ö l t e r w w w .ict.tu w ien.ac.at
How
do
I
come
up
with
a
good
metamodel?
II
In order to continuously improve and validatethe metamodelfor a domain, it has to be exercisedwith domain experts as
well as by the development team.
In order to achieve this, it is a good idea to use it duringdiscussions with stakeholders by formulating sentencesusing
the concepts in the meta model.
As soon as you find that you cannot express something usingsentencesbased on the meta model
Institute of
Computer Technology /99
sentencesbased on the meta model,
• you have to reformulate the sentence
• the sentence’s statement is just wrong
• you have to update the meta model.
- 68
w w w .ict.tu w ien.ac.at
How
do
I
come
up
with
a
good
metamodel?
III
Component Port owns * Interface implements 1
•
Example:• A component owns any number of ports. • Each port implements exactly oneinterface
Component
Required Port Provided Port
provides operations defined by
provides access to operations defined by
Institute of
Computer Technology /99
Each port implements exactly one interface.
• There are two kinds of ports: required ports and provided ports.
• A provided port provides the operations defined by its interface. • A required port provides access to operations defined by its interface.
- 69 -w w w .ict.tu w ien.ac.at
MDSD Process
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.atUse
Cases
for
Model
Transformations
Usually, model transformations are performed as a
concretization step. Rules (using terms from the underlying
metamodel) specify transformations
metamodel) specify transformations.
• Transforming a functional analysis model to a design model for a specific
platform
• Specializing general model to a more domain specific model.
• Creating different views of a model (varying level of detail, varying focus)
• Extracting subsets or aspects of a model (mainly for analysis and
Institute of
Computer Technology /99
Extracting subsets or aspects of a model (mainly for analysis and
constraint checking)
• Weaving different models together (e.g. aspects)
w w w .ict.tu w ien.ac.at
Modular
Transformations
Replace for other domains
Institute of
Computer Technology /99
w w w .ict.tu w ien.ac.at
Transformer
Do not base them on concrete syntax (usually error‐prone)
Use three‐pass approach:
1. Parse source model into AST 2. Transform source AST into target AST 3. Generate concrete syntax based target model
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Example:
Component
‐
Based
Integration
Institute of Computer Technology /99 w w w .ict.tu w ien.ac.at
Architectural
Aspect
of
MDSD
Model transformations map elements of the source model to
elements of the target model
Æa restricted set of well‐defined concepts is necessary
Æthat’s a characteristic of a well‐defined architecture
ÆMDSD requires a well‐defined architecture and forces a
conform software development
Institute of