Outline of the course
• Models and metamodels
• Revisiting UML: UML metamodel
• Definition of Domain Specific Languages
• Model transformations – Horizontal transformations
• Within-language: Refactoring; Between-languages: Model translation
– Vertical transformations • Within-language: Refinement; Between-languages: 2-way generation
• Tools of the trade Formal frameworks: AGG, EMF
Integrated Development Environments: Eclipse, NetBeans
– UML-Based tools
– Web-development: WebRatio
– Generation of Domain Specific Languages: MetaEdit+
• Hands-on: Defining a small application
2 Lesson1Introduction Advanced Software Engineering
Models and metamodels
• System: a set of resources organized to:
– Interact with the environment
• (Software system) Provide services
– Maintain its viability
• Model: a description of the system through different artefacts.
– Allows communication and reasoning about the system
• Metamodel: a model defining a language in which to construct models.
• Layering of models and metamodels (MDA)
– Instances
– Models
– Metamodels
– Metamodeling languages
• Recursive metamodeling
Lesson1Introduction 3 Advanced Software Engineering
A metamodel for system descriptions
(from L. Balmelli, D. Brown, M. Cantor, M. Mott, “Model-driven systems development”,
IBM Systems Journal, 45(3):569-585, 2006)
Lesson1Introduction 4 Advanced Software Engineering
Metamodels and domain models
• Metamodel as abstract syntax
• Domain model as constraints on possible realisations
• From a metamodel to a model
– Model instance of language defined by metamodel
– Metamodel contains metaclasses and meta-relationships
– Model classes and relationships instances of meta-elements
• From domain model to system model
– System model specialises and extends domain model
– Reuse or specialisation of notions
– Instances define system configuration
Lesson1Introduction 5 Advanced Software Engineering
From domain models to metamodels
• Transformations of classes into metaclasses
• Transformation of classes into stereotypes
• Definition of mechanisms for class generation
• Constraints on possible realisations
6 Lesson1Introduction Advanced Software Engineering
Extent of domains
• General domains
– E.g. banking, business, automotive, physics, media
• Technical spaces
– E.g. software platforms, UI generation, real-time
applications
• Specific domains
– E.g. a bank, a company, EJB, CORBA
7 Lesson1Introduction Advanced Software Engineering
An example of Model-based development
From use case diagrams …
… to UML class diagrams …
… to Java
• Abstract representations on metamodel graph
• Graph transformations on metamodel elements
• Three different metamodels involved
Lesson1Introduction 8 Advanced Software Engineering
CIM
(Use case
language)
From use case diagrams …
Lesson1Introduction 9 Advanced Software Engineering
From use case diagrams …
Lesson1Introduction 10 Advanced Software Engineering
Metamodel representation
(UML Class Diagram language)
Transformations
1 : Classifier
name=X
mk: Attribute
: UseCase
name=Y
ownedUseCase
2 : Class
name=X
:=
2 : Class
name=X
1 : Classifier
name=X mk: Attribute
: Operation
name=lowerCase(Y)
ownedOperation
: Classifier
name=X
mk: Attribute
: UseCase
ownedUseCase :=
… to class diagrams
:1: Classifier
name=X :=
: Class
name=X
1 : Classifier
name=X
mk: Attribute mk: Attribute
Lesson1Introduction 11 Advanced Software Engineering
: Property
ownedProperty
Analogous rule
for properties
Transformations Result
: Class
name="Account"
: Operation
name="deposit"
ownedOperation
: Operation
name="withdraw"
: Operation
name="check"
Account
deposit()
check()
withdraw()
Lesson1Introduction 12 Advanced Software Engineering
: Operation
name=“transfer"
balance : float = 0.0
: Property
name=“balance"
ownedAttribute
: Class
name=“Transaction" ownedOperation Transaction
transfer()
Metamodel representation
wth: Operation
name=“withdraw”
dep: Operation
name=“deposit”
chk: Operation
name=“check”
ac : Class
name=“Account”
ownedOperation
ownedOperation
ownedOperation
PIM
(Class diagram language) Account
withdraw()
deposit()
check()
From UML class diagrams …
Lesson1Introduction 14 Advanced Software Engineering
Transformations
: Class
name=X
mk: Attribute
: Operation
name=Y
ownedOperation :=
1 : Class
name=X
mk: Attribute
: Operation
name=Y
ownedOperation
2 : class
name=X
:=
2 : class
name=X
1 : Class
name=X
mk: Attribute
: method
name=Y
: type
name=“boolean”
… to Java
1 : Class
name=X :=
: class
name=X mk: Attribute
1 : Class
name=X mk: Attribute
Lesson1Introduction 15 Advanced Software Engineering
Analogous rule
for attribute
name=“withdraw”
dep: method
name=“deposit”
chk: method
name=“check”
ac : class
name=“Account”
wth: method Metamodel representation : type
name=“boolean”
: type
name=“boolean”
: type
name=“boolean”
PSM
(Java language) class Account {
boolean withdraw();
boolean deposit();
boolean check();
}
Further transformations needed to flesh out methods
Resulting Java code
Lesson1Introduction 16 Advanced Software Engineering
Specification of behaviours
wth: method
name=“withdraw”
public boolean withdraw(float amount) {
if(amount<0) return false;
else if(amount>=0) {
if(balance<amount) return false;
else if (balance>=amount) {
removeAmountFromBalance(amount);
sendSignal("ServeAmountToCustomer");
}
}
return true
} Lesson1Introduction 20 Advanced Software Engineering
Specification of behaviours: SD
public boolean transfer (float amount, Account otherAccount ) {
boolean check1, check2 = false;
check1 = otherAccount.deposit(amount);
if (check1) check2 = withdraw(amount);
return check2;
}
Lesson1Introduction 21 Advanced Software Engineering
Specification of behaviours: stereotyped SD public boolean transfer (float amount, Account otherAccount, custAccount ) {
boolean check1, check2 = false;
Transaction trans = new Transaction("transfer", amount, custAccount, otherAccount, this);
check1 = trans.PREPARE("deposit");
if (check1) {
check2 = trans.PREPARE("withdraw");
if (check2) trans.COMMIT();
else trans.ROLLBACK();
}
else trans.ROLLBACK();
return check2;
}
Lesson1Introduction 22 Advanced Software Engineering
Integrated Development Environments
• Eclipse – IDE for Java
– Plugins provide extensions to other modeling or programming languages
– Set of transformations available: refactoring
– Own meta-modeling facility
• Netbeans – Support to different languages integrated
– Set of transformations available: refactoring, pattern conformance.
– Support to generation towards different platforms
• MetaEdit+ – Definition of metamodels.
– Generation of code to manage models
– Distinction between library and generated code
• WebRatio – (I)DE for Web development and deployment
– Based on WebML, extension of UML + navigation information
Lesson1Introduction 23 Advanced Software Engineering
Recommended readings
• OMG documentation on UML and MDA
• Stefano Ceri, Piero Fraternali, Aldo Bongio, Marco
Brambilla, Sara Comai, Maristella Matera, Designing Data
Intensive Web Applications, Morgan Kauffman, 2003
• Markus Völter, Thomas Stahl, Jorn Bettin, Arno
Haase, Simon Helsen, Model-Driven Software
Development: Technology, Engineering, Management,
Wiley 2006
• Markus Völter, DSL Engineering - Designing,
Implementing and Using Domain-Specific Languages,
http://voelter.de
• Steven Kelly, Juha-Pekka Tolvanen, Domain-Specific
Modeling: Enabling Full Code Generation, Wiley 2008
Lesson1Introduction 24 Advanced Software Engineering
Lesson1Introduction 25
http://wwwusers.di.uniroma1.it/~advingsoft
Advanced Software Engineering