+ All Categories
Home > Documents > The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1)...

The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1)...

Date post: 12-Mar-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
269
© Copyright Malina Software The ―Theory‖ and Practice of Modeling Language Design (for Model-Based Software Engineering) Bran Selić Malina Software Corp. Zeligsoft (2009) Ltd. Simula Research Labs, Norway University of Toronto, Carleton University [email protected]
Transcript
Page 1: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software

The ―Theory‖ and Practice of Modeling Language Design (for

Model-Based Software Engineering)

Bran Selić Malina Software Corp.

Zeligsoft (2009) Ltd. Simula Research Labs, Norway

University of Toronto, Carleton University

[email protected]

Page 2: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 2

SC_MODULE(producer)

{

sc_outmaster<int> out1;

sc_in<bool> start; // kick-start

void generate_data ()

{

for(int i =0; i <10; i++) {

out1 =i ; //to invoke slave;}

}

SC_CTOR(producer)

{

SC_METHOD(generate_data);

sensitive << start;}};

SC_MODULE(consumer)

{

sc_inslave<int> in1;

int sum; // state variable

void accumulate (){

sum += in1;

}

SC_CTOR(consumer)

{

SC_SLAVE(accumulate, in1);

sum = 0; // initialize };

SC_MODULE(top) // container

{

producer *A1;

consumer *B1;

sc_link_mp<int> link1;

SC_CTOR(top)

{

A1 = new producer(“A1”);

A1.out1(link1);

B1 = new consumer(“B1”);

B1.in1(link1);}};

A Programming Language SampleA Programming Language Sample

Page 3: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 3

…and its Model…and its Model

«sc_slave»«sc_slave»

B1B1:consumer:consumer «sc_method»«sc_method»

A1:A1:producerproducer start out1 in1

«sc_link_mp»

link1

Page 4: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 4

SC_MODULE(producer)

{

sc_outmaster<int> out1;

sc_in<bool> start; // kick-start

void generate_data ()

{

for(int i =0; i <10; i++) {

out1 =i ; //to invoke slave;}

}

SC_CTOR(producer)

{

SC_METHOD(generate_data);

sensitive << start;}};

SC_MODULE(consumer)

{

sc_inslave<int> in1;

int sum; // state variable

void accumulate (){

sum += in1;

}

SC_CTOR(consumer)

{

SC_SLAVE(accumulate, in1);

sum = 0; // initialize };

SC_MODULE(top) // container

{

producer *A1;

consumer *B1;

sc_link_mp<int> link1;

SC_CTOR(top)

{

A1 = new producer(“A1”);

A1.out1(link1);

B1 = new consumer(“B1”);

B1.in1(link1);}};

Spot the Difference…Spot the Difference…

B1B1:consumer:consumer «sc_slave»«sc_slave»

B1B1:consumer:consumer «sc_method»«sc_method»

A1:A1:producerproducer start out1 in1

«sc_link_mp»

link1

Page 5: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 5

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Model Transformations

Summary

Page 6: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 6

Why is Software so Problematic?Why is Software so Problematic?

COMPLEXITY!

The machines we construct with computer software are often required to realize complex functionality

...and it has to interact with a physically complex world (including the hardware that runs it)

A useful distinction to keep in mind:

Essential complexity

Immanent to the problem

Cannot be eliminated by technology or method

Accidental complexity

Usually due to technology or methods used

This is the one we can fix

Page 7: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 7

Coping with ComplexityCoping with Complexity ABSTRACTION: Selective reduction of information of a

system which preserves its salient properties relative to a given set of concerns

Often, our only coping mechanism

SYSTEM

Page 8: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 8

Model(s)

System under

study

Models = Outcomes of AbstractionModels = Outcomes of Abstraction

A model is a set of ―statements‖ about a system under study [Seidewitz]*

Involves three core elements:

InterpretationInterpretation

(Abstraction)(Abstraction)

* E. Seidewitz, “What models mean”, IEEE Software, Sept./Oct. 2003

Page 9: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 9

Engineering ModelsEngineering Models

ENGINEERING MODEL: A selective representation of some system that captures accurately and concisely all of its essential properties of interest for a given set of concerns

• We don‘t see everything

• adjusted

• We don‘t see everything at once

• What we do see is adjusted to human understanding

Page 10: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 10

Why Do Engineers Build Models?Why Do Engineers Build Models?

To understand

...problems and solutions

Knowledge acquisition

To communicate

...understanding and design intent

Knowledge transfer

To predict

...the interesting characteristics of system under study

Models as surrogates

To specify

...the implementation of the system

Models as ―blueprints‖

Page 11: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 11

Types of Engineering ModelsTypes of Engineering Models

Descriptive: models for understanding, communicating, and predicting

E.g., scale models, mathematical models, qualitative models, documents, etc.

Tend to be highly abstract (detail removed)

Prescriptive: models as specifications

E.g., architectural blueprints, circuit schematics, state machines, pseudocode, etc.

Tend to be detailed so that the specification can be implemented

Q: Is it useful to have models that can

serve both kinds of purposes?

Page 12: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 12

Characteristics of Useful Engineering ModelsCharacteristics of Useful Engineering Models

Purposeful:

Constructed to address a specific set of concerns/audience

Abstract

Emphasize important aspects while removing irrelevant ones

Understandable

Expressed in a form that is readily understood by observers

Accurate

Faithfully represents the modeled system

Predictive

Can be used to answer questions about the modeled system

Cost effective

Should be much cheaper and faster to construct than actual system

To be useful, engineering models must satisfy at least these characteristics!

Page 13: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 13

Modeling Software

Page 14: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 18

What‘s a Software Model?What‘s a Software Model?

SOFTWARE MODEL: An engineering model of a software system from one or more viewpoints specified using one or more modeling languages

E.g.:

B

A B 0..*

C

0..1 0..*

«import»

0..*

left:B right:B

m1

m4

m2

m3

Structural

(design-time)

view

Structural

(design-time)

view

a : A

left:B right:B c : C

Execution

(run-time)

view

Execution

(run-time)

view

Page 15: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 19

Classical SW Modeling: SA/SDClassical SW Modeling: SA/SD

―…bubbles and arrows, as opposed to programs, …never crash‖

-- B. Meyer ―UML: The Positive Spin‖

American Programmer, 1997

Monitor PH

Raise PH

Control PH

PH reached X

Current PH

start

stop

Input valve control

Modeling languages Modeling languages have yet to recover from this ―debacle‖

Q: What does this Q: What does this ―bubble‖ really mean?

Q: How is it implemented in code?

Page 16: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 21

―Classical‖ Modeling Languages―Classical‖ Modeling Languages

Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1)

Most of them were intended exclusively for constructing descriptive models

Informal ―sketching‖ [M. Fowler]*

No perceived need for precision

Languages are ambiguous and open to interpretation source of undetected miscommunication

*http://martinfowler.com/bliki/UmlAsSketch.html

Page 17: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 22

New Generation of Modeling LanguagesNew Generation of Modeling Languages

Formal languages designed for modeling

Support for both descriptive and prescriptive models

...sometimes in the same language

Key objectives:

Well-understood and precise semantic foundations

Can be formally (i.e., mathematically) analyzed (qualitative and quantitative analyses)

And yet, can still be used informally (―sketching‖) if desired

Page 18: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 23

Modeling Modeling vsvs Programming LanguagesProgramming Languages

The primary purpose and focus of programming languages is implementation

The ultimate form of prescription

Implementation requires total precision and ―full‖ detail

Takes precedence over description requirements

To be useful, a modeling language must support description

I.e., communication, prediction, and understanding

These generally require omission of ―irrelevant‖ detail such as details of the underlying computing technology used to implement the software

Page 19: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 24

Computer LanguagesComputer Languages

Much of the evolution of computer languages is motivated by the need to be more human-centric

Application

specific

Computing

technology

specific

Assemblers (2G), machine languages (1G)

Classical (3G) programming

languages

Modeling languages

Implementation

level

Compiler Compiler filled detailfilled detail

Can we do the same here ?

Degree of (computing technology) abstraction

Page 20: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 25

Components of a Modeling LanguageComponents of a Modeling Language

The definition of a modeling language consists of:

Set of language concepts/constructs (―ontology‖)

• e.g., Account, Customer, Class, Association, Attribute, Package

Rules for combining language concepts (well-formedness rules)

• e.g., ―each end of an association must be connected to a class‖ ABSTRACT

SYNTAX

CONCRETE SYNTAX (notation/representation)

• e.g., keywords, graphical symbols for concepts

• Mapping to abstract syntax concepts

SEMANTICS: the meaning of the language concepts

• Comprises: Semantic Domain and Semantic Mapping (concepts to domain)

Page 21: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 26

Semantics

Elements of a Modeling LanguageElements of a Modeling Language

Modeling Language

1 0..* Concrete Syntax

0..*

0..1

Semantics Domain

1..*

Abstract Syntax

1

1..* 0..*

Concrete Syntax

Mapping

0..*

Semantics Mapping

1

Page 22: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 27

ModelModel--Based Engineering (MBE)Based Engineering (MBE)

An approach to system and software development in which software models play an indispensable role

Based on two time-proven ideas:

switch (state) {

case„1:action1;

newState(„2‟);

break;

case„2:action2;

newState(„3‟);

break;

case‟3:action3;

newState(„1‟);

break;}

(2) AUTOMATION

S1

S3

S2

e1/action1

e2/action2

e3/action3

switch (state) {

case„1:action1;

newState(„2‟);

break;

case„2:action2;

newState(„3‟);

break;

case‟3:action3;

newState(„1‟);

break;}

(1) ABSTRACTION

S1

S3

S2

e1/action1

e2/action2

e3/action3

Realm of

Realm of modeling languages

Realm of Realm of tools

Page 23: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 28

ModelModel--Driven Architecture (MDA)™Driven Architecture (MDA)™

In recognition of the increasing importance of MBE, the Object Management Group (OMG) is developing a set of supporting industry standards

(1) ABSTRACTION (2) AUTOMATION

(3) INDUSTRY STANDARDS • UML 2

• OCL • MOF • SysML • SPEM • …etc.

http://www.omg.org/mda/ http://www.omg.org/mda/

Page 24: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 29

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Model Transformations

Summary

Page 25: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 30

Primary Language Design ConcernsPrimary Language Design Concerns

Who are the primary end users?

Authors / readers? (i.e., primary use cases)

What kind of models do they want?

Descriptive, prescriptive, or both?

What is the domain?

What is the application domain and what are its salient technical characteristics?

Page 26: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 31

Sidebar: Feature Diagram EssentialsSidebar: Feature Diagram Essentials

PC Purchase Configuration

3 GB RAM

1 GB RAM

Linux OS

Windows 7 OS

Extras

DVD drive

Display Screen

Printer

Mutually exclusive

Mutually exclusive alternatives (exclusive or)

Inclusive

(but, at least 1)

Inclusive-or alternatives (but, at least 1)

Mandatory

Mandatory sub-feature Optional

Optional sub-feature

Feature or Feature or concept

Page 27: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 32

Key Language Design ChoicesKey Language Design Choices Modeling Language

Features

Specification

Extension

Concrete Syntax

Model of Computation

Model Type

Precision Level

Abstraction Range

Scope

Some choices are interSome choices are inter-dependent

Page 28: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 33

Selecting Language ScopeSelecting Language Scope

A common opinion:

―Surely it is better to design a small language that is highly expressive, because it focuses on a specific narrow domain, as opposed to a large and cumbersome language that is not well-suited to any domain?‖

Which suggests:

Scope

Domain-Specific

General Purpose

But, this may be an oversimplificationBut, this may be an oversimplification

Page 29: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 34

Scope: How General/Specific?Scope: How General/Specific?

Generality often comes at the expense of expressiveness

Expressiveness: the ability to specify concisely yet accurately a desired system or property

Example:

• UML does not have a concept that specifies mutual exclusion devices (e.g. semaphore) to represent such a concept in our model, we would need to combine a number of general UML concepts in a particular way (e.g., classes, constraints, interactions)

...which may(?) be precise, but not very concise

It also comes at the cost of detail that is necessary to:

Execute models

Generate complete implementations

Page 30: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 35

Specialization: Inevitable TrendSpecialization: Inevitable Trend

Constant branching of application domains into ever-more specialized sub-domains

As our knowledge and experience increase, domain concepts become more and more refined

• E.g., simple concept of computer memory → ROM, RAM, DRAM, cache, virtual memory, persistent memory, etc.

One of the core principles of MBE is raising the level of abstraction of specifications to move them closer to the problem domain

• This seems to imply that domain-specific

• This seems to imply that domain-specific languages are invariably the preferred solution

• But, there are some serious hurdles here...

Page 31: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 36

The Case of Programming LanguagesThe Case of Programming Languages

Literally hundreds of domain-specific programming languages have been defined over the past 50 years

Fortran: for scientific applications

COBOL for ―data processing‖ applications

Lisp for AI applications

etc.

Some relevant trends

Many of the original languages are still around

More often than not, highly-specialized domains still tend to use general-purpose languages with specialized domain-specific program libraries and frameworks instead of domain-specific programming languages

In fact, the trend towards defining new domain-specific programming languages seems to be diminishing

Why is this happening?

Page 32: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 37

Success* Criteria for a Language (1)Success* Criteria for a Language (1)

Technical validity: absence of major design flaws and constraints

Ease of writing correct programs

Expressiveness

Simplicity: absence of gratuitous/accidental complexity

Ease of learning

Run-time efficiency: speed and (memory) space

Familiarity: proximity to widely-available skills

E.g., syntax

* ―Success‖

* ―Success‖ language is adopted by a substantive development community and used with good effect for real-world applications

Page 33: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 38

Success Criteria for a Language (2)Success Criteria for a Language (2)

Language Support & Infrastructure:

Availability of necessary tooling

Effectiveness of tools (reliability, quality, usability, customizability, interworking ability)

Availability of skilled practitioners

Availability of teaching material and training courses

Availability of program libraries

Capacity for evolution and maintenance (e.g., standardization)

Page 34: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 39

Sidebar: Basic Tooling CapabilitiesSidebar: Basic Tooling Capabilities

Essential

Model Authoring

Model validation (syntax, semantics)

Model export/import

Document generation

Version management

Model compare/merge

Useful (to Essential)

Code generation

Model simulation/debug/trace

Model transformation

Model review/inspection

Collaborative development support

Language customization support

Test generation

Test execution

Traceability

Page 35: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 40

Language SizeLanguage Size

How complex (simple) should a language be to make it effective?

simple complex

Turing

machine

language

C Java PL/I Java +

Basic Java libs +

Java-based frameworks

C++

The art of computer language design lies in finding the right balance between expressiveness and simplicity

– Need to minimize accidental complexity while recognizing and respecting essential complexity

– Small languages solve small problems

– No successful language has ever gotten smaller

limited expressive

Page 36: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 41

Practical Issues of ScopePractical Issues of Scope

Practical systems often involve multiple heterogeneous domains

Each with its own ontology and semantic and dedicated specialists

Example: a telecom network node system

Basic bandwidth management

Equipment and resource management

Routing

Operations, administration, and systems management

Accounting (customer resource usage)

Computing platform (OS, supporting services)

Page 37: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 42

The Fragmentation ProblemThe Fragmentation Problem FRAGMENTATION PROBLEM: combining overlapping

independently specified domain-specific subsystems, specified using different DSLs, into a coherent and consistent whole (i.e., single implementation)

Network Node

Comm. Channel

Bandwidth Mgmt. System

Resource Mgmt. System

Call Processing System

Sadly, there are no generic composition (weaving) rules Sadly, there are no generic composition (weaving) rules – each case has to be handled individually

Page 38: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 43

Approach to Dealing with FragmentationApproach to Dealing with Fragmentation

Having a common syntactic and semantic foundations for the different DSLs seems as if it should facilitate specifying the formal interdependencies between different DSMLs

Common Abstract Syntax and Semantic Foundation

DSL1 Refinements

DSL1 Class Library

DSL2 Refinements

DSL2 Class Library

. . .etc.

NB: Same divide and conquer approach can be used to modularize complex languages

Core language base + independent sub-languages (e.g., UML)

Page 39: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 44

Selecting An Abstraction RangeSelecting An Abstraction Range

This decomposes into two separate questions:

What is a suitable level of abstraction of the language?

How much (implementation-level) detail should the language concepts include?

The answers depend on other design choices

Modeling Language Features

Specification

Extension

Concrete Syntax

Model of Computation

Model Type

Precision Level

Scope

Executable

Abstraction Range

Page 40: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 45

Abstraction Range of Computer LanguagesAbstraction Range of Computer Languages

Application

domain

specific

Computing

technology

specific

Modeling language concepts

How much detail do we

provide?

How far up do we go?

Normally determined by Normally determined by the type and level of description desired

Normally determined by Normally determined by the type and level of prescription desired

Page 41: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 46

Selecting a Precision LevelSelecting a Precision Level Modeling Language

Features

Specification

Extension

Concrete Syntax

Model of Computation

Model Type

Abstraction Range

Scope

Precision Level

Informal Formal

Ad Hoc Codified Precise Executable Implementation

Page 42: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 47

FormalityFormality

Based on a well understood mathematical theory with existing analysis tools

E.g., automata theory, abstract state machines, Petri nets, temporal logic, process calculi, queueing theory, Horne clause logic

NB: precise does not necessarily mean detailed

Formality provides a foundation for automated validation of models

Model checking (symbolic execution)

Theorem proving

However, the value of these is constrained due to scalability issues (―the curse of dimensionality‖)

It can also help validate the language definition

But, it often comes at the expense of expressiveness

Only phenomena recognized by the formalism can be expressed accurately

Page 43: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 48

Precision vs. DetailPrecision vs. Detail

A specification can be precise but still leave out detail:

E.g., we can identify a set very precisely without necessarily specifying the details associated with its members

Bob

Karl

Alice

Jill

Peggy

Adults

Fred

We state very

its members

We state very precisely as to what constitutes the set of Adults of some population (age 21) without being specific about details such as names or genders of its members

back

Page 44: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 49

Ad Hoc ―Languages‖Ad Hoc ―Languages‖

Mostly notations created for specific cases (not intended for reuse)

Used exclusively for descriptive purposes

No systematic and comprehensive specification of syntax or semantics

Appeal to intuition

Services LayerServices Layer

RUFRUF

SocketsSockets MemoryMemory ManagerManager

CasterCaster

PrintPrint FileFile

CoreCore

BStackBStack

CStackCStack

PosterPoster

MessagesMessages

LogLog

Page 45: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 50

Codified LanguagesCodified Languages

Example: UML 1.x, OMT, SysML, ...

Characteristics:

Defined: An application-independent language specification exists

Some aspects of the language are fully defined (usually: concrete syntax, semantics)

Semantics usually based on natural language and other informal specification methods

Designed primarily for descriptive modeling

But, may also be used partly for specification (e.g., partial code generation/code skeletons)

Page 46: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 51

Precise LanguagesPrecise Languages

Examples: Object Constraint Language (OCL), Layered Queueing Networks (LQN)

Fully defined semantics (domain and mapping)

High level of abstraction but typically cover relatively small range

I.e., lacking detail for execution or implementation

Often declarative

Mostly designed for prescription (e.g., prediction and analysis), but may also be used for specification

Page 47: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 52

Executable LanguagesExecutable Languages

―Models that are not executable are like cars without engines‖, [D. Harel]

Examples: Modelica, Matlab

A subcategory of precise languages covering a range that includes sufficient detail for creating executable models

But, may be missing detail required for automatic generation of implementations

Often based on operational semantics that may not be easily analyzed by formal methods (due to scalability issues)

Rationale:

Enables early detection of design flaws

Helps develop engineering intuition and confidence

Page 48: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 53

How We Can Learn From ModelsHow We Can Learn From Models

X = cos (h + p/2)

+ x*5

X = cos (h + p/2)

+ x*5

? ? By formal analysis

– reliable (provided the models are accurate)

– formal methods do not scale very well

? ?

X = cos (h + p/2)

+ x*5

X = cos (h + p/2)

+ x*5

By execution

– more reliable than inspection

– direct experience/insight

X = cos (h + p/2) + x*5

X = cos (h + p/2) + x*5

? ?

By inspection

– mental execution

– unreliable

Page 49: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 54

Executable Modeling Tool RequirementsExecutable Modeling Tool Requirements

Ability to execute a model on a computer and observe its behavior

With possible human intervention when necessary

Key capabilities

Controllability: ability to start/stop/slow down/speed up/drive execution

Observability: ability to view execution and state in model (source) form

Partial model execution: ability to execute abstract and incomplete models

Page 50: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 55

Implementation (Modeling) LanguagesImplementation (Modeling) Languages

Computer languages that:

Provide concepts at high levels of abstraction suitable for descriptive purposes, and also

Include detailed-level concepts such that the models can provide efficient implementations through either automatic code generation or interpretation

Examples: UML-RT, Rhapsody UML, etc.

Page 51: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 56

Language Abstraction LevelsLanguage Abstraction Levels

Application

specific

Computing

technology

specific

Assemblers (2G), machine languages (1G)

Classical (3G) programming

languages

Modeling languages

Implementation

level

Compiler Compiler filled detailfilled detail

Degree of (computing technology) abstraction

Page 52: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 57

Full Range Modeling LanguagesFull Range Modeling Languages

A number of ―descriptive‖ modeling languages have evolved into fully-fledged implementation languages

Application

specific

Computing

technology

specific

Assemblers (2G), machine languages (1G)

Classical (3G) programming

languages

Modeling languages

Implementation

level

Compiler Compiler filled detailfilled detail

Degree of (computing technology) abstraction

Action languages

Translator Translator filled filled detaildetail

e.g., UML e.g., UML e.g., UML e.g., UML Action Action LanguageLanguage

Page 53: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 58

Precision Level CategoriesPrecision Level Categories

A more refined categorization based on degree of ―formality‖

Precision of definition, internal consistency, completeness, level of detail covered

PRECISE Defined, formal, consistent Analysis, Prediction

CODIFIED Defined, informal Documentation,

Analysis

AD HOC Undefined, informal Documentation,

Analysis (no reuse)

EXECUTABLE Defined, formal, consistent,

complete Analysis, Prediction

IMPLEMENTATION Defined, formal, consistent,

complete, detailed Prediction,

Implementation

Category Characteristics Primary Purpose

Page 54: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 59

refinerefine

NotStarted

Started

start

producer

Modern MBSE Development StyleModern MBSE Development Style

Models can be refined continuously until the application is fully specified in the extreme case the model can become the system that it was modeling!

««sc_methodsc_method»»

producerproducer start out1

NotStarted

Started

start

producer

St1 St2

void void generate () {for (int i=0; i<10; i++) {out1 = i;}}

/generate ( )

Page 55: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 60

But, if the Model is the System...But, if the Model is the System...

...are we not losing the key abstraction characteristic of models?

NotStarted

Started

start

producer

St1 St2

void void generate () {for (int i=0; i<10; i++) {out1 = i;}}

/generate ( )

• The computer offers a

any desired level of

• The computer offers a uniquely capable abstraction device:

Software can be represented from any desired viewpoint and at any desired level of abstraction

The abstraction resides within the model and can be extracted automatically

NotStarted

Started

start

producer

Model

Xform

Page 56: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 61

The Unique Nature of SoftwareThe Unique Nature of Software

Software is a unique in that a program and its model share the same medium – the computer

The two can be formally linked to each other

This formal linkage can be realized by automated transformations implemented on a computer

Page 57: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 62

A Unique Feature of SoftwareA Unique Feature of Software

Software has the unique property that it allows Software has the unique property that it allows us to directly evolve models into implementations without fundamental discontinuities in the expertise, tools, or methods!

High probability that key design High probability that key design decisions will be preserved in the implementation and that the results of prior analyses will be valid

Page 58: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 63

Automatic Code GenerationAutomatic Code Generation

A form of model transformation (model to text)

To a lower level of abstraction

State of the art:

All development done via the model (i.e., no modifications of generated code)

Size: Systems equivalent to ~ 10 MLoC

Scalability: teams involving hundreds of developers

Performance: within ±5-15% of equivalent manually coded system

Page 59: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 64

Major Telecom Equipment ManufacturerMajor Telecom Equipment Manufacturer

MBE technologies used

UML, Rational Technical Developer, RUP

Example 1: Radio Base Station

2 Million lines of C++ code (87% generated by tools)

150 developers

Example 2: Network Controller

4.5 Million lines of C++ code (80% generated by tools)

200 developers Benefits

80%

30%

Benefits

80% fewer bugs

30% productivity increase

Page 60: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 67

Styles of MBEStyles of MBE

“Who cares

about the

code?”

Model

Model only

“What’s a

model?”

Code

Code only

“The code is

the model”

Model

Code

Code

Visualization

visualize

“The model is

the code”

Model

Code

Model-centric

generate

Levels of

Abstraction

Automation

Time

“Manage

code and

model”

Model

Code

Round Trip

Engineering

synchronize

Page 61: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 68

NB: Slide idea borrowed from an itemis AG presentation

Roundtrip EngineeringRoundtrip Engineering

Implementation

transformation

Reverse

engineering

Page 62: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 69

State of the PracticeState of the Practice

Levels of

Abstraction

Automation

Time

“Who cares

about the

code?”

Model

Model only

“What’s a

model?”

Code

Code only

“The code is

the model”

Model

Code

Code

Visualization

visualize

“The model is

the code”

Model

Code

Model-centric

generate

“Manage

code and

model”

Model

Code

Round Trip

Engineering

synchronize

State of the

Art

Predominant

State of the

Practice

Page 63: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 70

Selecting a Model TypeSelecting a Model Type Modeling Language

Features

Specification

Extension

Concrete Syntax

Model of Computation

Precision Level

Abstraction Range

Scope

Model Type

Descriptive Prescriptive

With the With the

support both types support both types of modelsof models

With the With the appropriate choice appropriate choice of of Abstraction Abstraction RangeRange and and Precision Level Precision Level in in combination with combination with suitable model suitable model transforms, it is transforms, it is possible to define possible to define languages that languages that support both types support both types of modelsof models

Page 64: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 71

Pragmatics: Multiple Models NeededPragmatics: Multiple Models Needed

In reality, it is generally not practical to have a single model that covers all possible levels of abstraction

But, it is possible to formally (i.e., electronically) couple different models via persistent model transforms

Abstract Model

m'

a' b'

Detailed Model

a1 a2 c1 b1

b2 c2

m1 m2

m3

m6

m4 m5

NB: The same language and tools are used for

NB: The same language and tools are used for both models

Page 65: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 72

Selecting a Model of ComputationSelecting a Model of Computation

Model of Computation: A conceptual framework (paradigm) used to specify how a (software) system realizes its prescribed functionality

Where and how does behavior (i.e., computation) occur

Derived usually from domain semantics

Modeling Language Features

Specification

Extension

Concrete Syntax

Model of Computation

Model Type

Precision Level

Abstraction Range

Scope

Page 66: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 73

Key Dimensions of Key Dimensions of MoCMoC

Involves a number of inter-related decisions

Model of Computation

Computational Paradigm

Concurrency Paradigm

Causality Paradigm

Distribution Paradigm

Semantic Domain

Interaction Paradigm

Page 67: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 74

Selecting a Computational ParadigmSelecting a Computational Paradigm

Computational Paradigm

ControlFlow Based

DataFlow Based

Object Oriented

Flow Based

Model of Computation

Concurrency Paradigm

Causality Paradigm

Distribution Paradigm

Semantic Domain

Interaction Paradigm

Page 68: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 75

Other Other MoCMoC DimensionsDimensions

Concurrency paradigm: does computation occur sequentially (single thread) or in parallel (multiple threads)?

Causality paradigm: what causes behavior

event driven, control driven, data driven (functional), time driven, logic driven, etc.

Execution paradigm: nature of behavior execution

Synchronous (discrete), asynchronous, mixed (LSGA)

Interaction paradigm: how do computational entities interact

synchronous, asynchronous, mixed

Distribution paradigm: does computation occur in a single site or multiple?

Multisite ( concurrent execution) vs. single site

If multisite: Coordinated or uncoordinated (e.g., time model, failure model)?

NB: These choices require a deep understanding of computing NB: These choices require a deep understanding of computing technology and cannot be made easily by non-experts

Page 69: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 76

SemanticsSemantics

The meaning of language concepts

Specified by relating them to concepts of a ―well-understood‖ different domain

E.g.,

UML Class

(concept)

Shared human

knowledge

A class describes

a set of objects

that share the

same

specifications of

features,

constraints, and

semantics

Semantic Mapping Semantic Domain

Page 70: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 77

―Formal‖ Semantics―Formal‖ Semantics

The mapping and the domain are defined using precisely defined domains and mappings

Formal mathematical frameworks (e.g., first-order logic, abstract state machines, process algebras, IO streams, etc.) or

Executable computer languages (e.g., Java, Prolog)

• Which may themselves have a formal semantics definition

Example:

Base UML (bUML) is defined in terms of mappings to the Process Specification Language (PSL), which is itself based on situational calculus and first order logic

Foundational UML (fUML) is defined operationally as a bUML program

Page 71: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 78

Selecting a Semantics DomainSelecting a Semantics Domain

Avoid sophisticated mathematical formalisms

Difficult to understand and verify (unless suitable tools are available)

Operational methods are generally preferred in practice

Choose a domain with existing tool support

Enables verification of the semantics specification itself

Enables verification/prediction of model properties

Examples:

• Abstract state machines

• Temporal Logic of Actions

• Process Specification Language

Page 72: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 79

Pragmatics: Multiple (Nested) Pragmatics: Multiple (Nested) MoCsMoCs

Some modeling languages use a combination of MoCs (e.g., UML)

«sc_method»

producer start out1

NotStarted

Started

start

producer

St1 St2

void void generate () {for (int i=0; i<10; i++) {out1 = i;}}

/generate ( )

EventEvent driven driven EventEvent--driven driven concurrent concurrent MoCMoC

ControlControl--flow flow driven driven MoCMoC

Distributed Distributed MoCMoC

Page 73: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 80

Selecting a Concrete SyntaxSelecting a Concrete Syntax Modeling Language

Features

Specification

Extension

Model of Computation

Model Type

Precision Level

Abstraction Range

Scope

Concrete Syntax

Surface Syntax

Interchange Syntax

Page 74: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 81

State of the ArtState of the Art

―Very little is documented about why particular graphical conventions are used. Texts generally state what a particular symbol means without giving any rationale for the choice of symbols or saying why the symbol chosen is to be preferred to those already available. The reasons for choosing graphical conventions are generally shrouded in mystery.‖ [S. Hitchman]*

* S. Hitchman, “The Details of Conceptual Modeling Notations are Important –

A Comparison of Relationship Normative Language”, Comms. of the AIS, 9, 2002.

Page 75: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 82

Concrete Concrete Syntax DesignSyntax Design

Two main forms:

For computer-to-computer interchange (e.g., XMI)

For human consumption – ―surface‖ syntax

Designing a good surface syntax is the area that we understand least

If a primary purpose of models is communication and understanding, what syntactical forms should we use for a given language?

D. Moody, ―The ‗Physics‘ of Notations: Toward a Scientific Basis for Constructing Visual Notations in Software Engineering‖, IEE Transactions on Software Engineering, vol. 35, no.6, Nov./Dec. 2009

Requires multi-disciplinary skills

Domain knowledge

Computer language design

Cognitive science

Psychology

Cultural Anthropology

Graphic design

Computer graphics

Page 76: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 83

A Couple of Thoughts on GraphicsA Couple of Thoughts on Graphics

―Whenever someone draws a picture to explain a program, it is a sign that something is not understood.‖ – E. Dijkstra*

―Yes, a picture is what you draw when you are trying to understand something or trying to help someone understand.‖ – W. Bartussek*

* Quoted in D.L. Parnas, “Precisely Annotated Hierarchical Pictures of Programs”,

McMaster U. Tech Report, 1998.

Page 77: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 84

Text vs. Graphics: ExampleText vs. Graphics: Example

Off

On

Starting Stopping

start/a1()

started

stop/a2()

stopped

State: Off, On, Starting, Stopping;

Initial: Off;

Transition:

{source: Off;

target: Starting;

trigger: start;

action: a1();}

Transition:

{source: Starting;

target: On;

trigger: started;}

Transition:

{source: On:

target: Stopping;

trigger: stop;

action: a2();}

Transition:

{source: Stopping;

target: Off;

trigger: stopped;}

Page 78: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 85

Surface SyntaxSurface Syntax

Textual forms

Same as for programming languages: linear sequence of symbols

Usually specified as a type of BNF with terminals; e.g.:

<add-statement> ::= „ADD‟ <left-bracket> <[arguments-list]> <right-bracket> <left-bracket> ::= „(„

Tabular forms

Constrained 2-dimensional

E.g., spreadsheets, Parnas tables

Graphical forms

More complex: unconstrained 2-dimensional

• Actually 2.5 dimensional – concept of Z-dimensions (overlapping graphics)

More flexible: user can choose which parts of the model to represent and how!

• E.g., shape, line/fill styles, x-y position, size, font, etc.

DepositFunds DepositFunds vs.

Surface Syntax

Graphical Textual

Tabular

Page 79: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 86

Guidelines Guidelines for Effective for Effective Visual DesignVisual Design

Cognitive Effectiveness

3. Perceptual Immediacy

4. Visual Expressiveness

2. Perceptual Discriminability

5. Graphic Parsimony

6. Cognitive fit

1. Semiotic Clarity

1:1 correspondence 1:1 correspondence 1:1 correspondence 1:1 correspondence between concepts between concepts and symbolsand symbols

Different concepts Different concepts Different concepts Different concepts should have should have different symbolsdifferent symbols

Symbols should Symbols should suggest meaningsuggest meaning

Use full range Use full range Use full range Use full range of visual of visual variablesvariables

Number of different Number of different

managablemanagable

Number of different Number of different graphical conventions graphical conventions should be should be cognitevlycognitevly managablemanagable

Different visual Different visual

audiencesaudiences

Different visual Different visual dialects for dialects for different different audiencesaudiences

* D. Moody and J.v.Hillegersberg, “Evaluating the Visual Syntax of UML: An Analysis

of the Cognitive Effectiveness of the UML Suite of Diagrams”,

Page 80: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 87

Extending an Existing Language?Extending an Existing Language? Modeling Language

Features

Specification

Concrete Syntax

Model of Computation

Model Type

Precision Level

Abstraction Range

Scope

Extension

Define Extend

Refine

Page 81: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 88

Approaches to DSML DesignApproaches to DSML Design

1. Define a completely new language from scratch

2. Extend an existing language: add new domain-specific concepts to an existing (base) language

3. Refine an existing language: specialize the concepts of a more general existing (base) language

Page 82: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 89

Refinement Refinement vsvs ExtensionExtension

Semantic space = the set of all valid programs that can be specified with a given computer language

Refinement: subsets the semantic space of the base language (e.g., UML profile mechanism)

Enables reuse of base-language infrastructure

Extension: intersects the semantic space of the base language

Base Language SpaceBase Language Space

Refinement Extension

Page 83: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 90

Comparison of ApproachesComparison of Approaches

ApproachApproach ExpressiveExpressive

PowerPower

Ease of Ease of

Lang.DesignLang.Design

InfrastructureInfrastructure

ReuseReuse

MultimodelMultimodel

IntegrationIntegration

New Language High Low Low Low

Extension Medium Medium Medium Medium

Refinement Low High High High

Page 84: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 91

Define, Refine, or Extend?Define, Refine, or Extend?

Depends on the problem at hand

Is there significant semantic similarity between the base language metamodel and the new language metamodel?

• Does every new language concept represent a semantic specialization of some base language concept?

• No semantic or syntactic conflicts?

Is language design expertise available?

Is domain expertise available?

Cost of establishing and maintaining a language infrastructure?

Need to integrate models with models based on other DSMLs?

The ability to reuse the infrastructure of a language has often led to refinement or extension as the preferred choice

Not necessarily optimal from a purely technical viewpoint

E.g., Z.109 (SDL profile of UML), SysML4Modelica (SysML profile), SystemC (UML profile), AADL (UML profile), MoDAF/DoDAF (UML profile)…

Page 85: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 92

Selecting a Language Specification MethodSelecting a Language Specification Method

What methods should be used to specify a modeling language?

Modeling Language Features

Specification

Extension

Concrete Syntax

Model of Computation

Model Type

Precision Level

Abstraction Range

Scope

Page 86: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 93

Summary: Modeling Language DesignSummary: Modeling Language Design

Modeling language design is still much more of an art than a science

Few reference texts; no consensus

Doing it well requires a rare combination of skills:

Understanding of modeling technologies, computer language technologies, domain knowledge, and even non-technical knowledge such as cognitive psychology

Many complex technical and non-technical design choices and tradeoffs need to be made

DSMLs are an important and inevitable trend, but the often advertised notion of ―end-user language design‖ is far from practical reality

Page 87: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 94

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Model Transformations

Summary

Page 88: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 95

Semantics

Elements of a Modeling LanguageElements of a Modeling Language

Modeling Language

1 0..* Concrete Syntax

0..*

0..1

Semantics Domain

1..*

Abstract Syntax

1

1..* 0..*

Concrete Syntax

Mapping

0..*

Semantics Mapping

1

Page 89: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 96

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Specifying Abstract Syntax

Specifying Concrete Syntax

Specifying Semantics

Case Study: UML

Model Transformations

Summary

Page 90: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 97

Data and MetadataData and Metadata

Legend:

Line A

Line B

Line C

Line D

The data

The The metadata

Page 91: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 98

MetamodelingMetamodeling ApproachesApproaches

Abstract syntax specified by a model using a domain-specific modeling language

i.e., a language for defining abstract syntaxes

Metamodeling language

Notable metamodeling languages

OMG‘s MetaObject Facility (MOF)

Eclipse‘s Eclipse Modeling Framework (EMF)

Xactium‘s XMF

Page 92: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 99

MetamodelsMetamodels vs. Other Specification Stylesvs. Other Specification Styles

Models explicitly capture potentially intricate relationships between the elements of a model

Models map naturally to graphs

BNF specifications are tuned to linear text-based syntactical forms

Typically parsed into ―abstract syntax trees‖ (ASTs) that obscure some relationships need to rely on element identifiers to reconstitute them

Equivalent constraints apply to XML-based approaches

Still, XML is typically used to interchange model specs

Generated from models as a linear representation

Page 93: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 100

The OMG‘s 4The OMG‘s 4--Layer ―Architecture‖Layer ―Architecture‖

Real Objects (computer memory,

run-time environment)

Model (model repository)

Meta-Model (modeling tool)

CustomerOrderCustomerOrder

itemitem

quantityquantity

itemitem

quantityquantity

CustomerCustomer

idididid

Meta-Meta-Model (modeling tool)

ClassClass AssociationAssociation . . .

<sawdust><sawdust>

<2 tons><2 tons>

<sawdust><sawdust>

<2 tons><2 tons>

<DeliIceCream><DeliIceCream> <lard><lard>

<5 tons><5 tons>

<lard><lard>

<5 tons><5 tons>

01011 01011

01011

(M0)(M0)

(M1)(M1)

(M2 = UML, (M2 = UML,

CWM)CWM)

(M3 = MOF)(M3 = MOF) Class(MOF) . . .

«specifiedBy»

«representedBy» «representedBy» «representedBy»

«specifiedBy» «specifiedBy»

«specifiedBy»

Page 94: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 101

The Structure of MOF (simplified)The Structure of MOF (simplified)

UML Infrastructure

CMOF

EMOF

«merge»

Extension Extension

«merge»

Identifiers Identifiers

«merge»

Reflection Reflection

«merge»

Page 95: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 102

Essential MOF Concepts (Example)Essential MOF Concepts (Example)

Key concepts used to define an abstract syntax

Automobile

make : String

power : Integer

make : String

power : Integer

Person

driver 0..*

vehicle 0..2

Wheel w

3..*

Vehicle

Class

(concept)

Generalization

Generalization (relationship)

Association

Association (relationship)

Composition (relationship)

Package

construct)

Package (modularization

construct)

(driver.age <= 16) implies

(power <= 10)

Constraint

Constraint (well-formedness

rule)

Page 96: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 103

Example: EMOF Metamodel (Root)Example: EMOF Metamodel (Root)

Using MOF to define (E)MOF

Element

Comment

body : String body : String

NamedElement

name : String name : String

TypedElement Type

Metaclass = A MOF Metaclass = A MOF Class that models a Language Concept

0..*

0..1

Page 97: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 104

Example: EMOF Metamodel (simplified)Example: EMOF Metamodel (simplified)

TypedElement

Class

isAbstract : Boolean isAbstract : Boolean Property

isReadOnly : Boolean

default : String [0..1]

isComposite : Boolean

isDerived : Boolean

isReadOnly : Boolean

default : String [0..1]

isComposite : Boolean

isDerived : Boolean

0..*

Operation 0..*

Parameter 0..*

Type type

0..1

0..*

opposite

0..1

Page 98: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 105

The Meaning of Class ModelsThe Meaning of Class Models

A key element of abstract syntax definition

What does this model represent?

There is much confusion about the meaning of this type of diagram (model)

Questions:

What do the boxes and lines represent?

How many Types are represented in this diagram?

What does ―type‖ mean?

What does ―0..*‖ mean?

TypedElement Type type

0..1

0..*

Page 99: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 106

Example: Two Populations with RelationshipsExample: Two Populations with Relationships

Bob

Karl

Alice

Jill

Peggy

Children Adults

Fred

Cory

Dee

Guy

Hayley

Ida

Les

Page 100: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 107

Some Facts We Can StateSome Facts We Can State

Particular statements (propositions):

Bob has no children (in the set Children)

Karl is the father of Dee and Ida

Karl and Jill are the parents of Cory

Fred and Peggy are the parents of Guy

Peggy is the mother of Hayley

Alice is the mother of Les

General statements (predicates – through abstraction):

Children can have one or two Adult parents

Some Adults are parents of Children

Every Person has a name and a gender

Page 101: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 108

Classes and Associations in MOF (and UML)Classes and Associations in MOF (and UML)

Class: A specification of a collection of object instances characterized by possessing the same set of features and behaviours

Association: A specification of a collection of links whose ends conform respectively to the same type

Page 102: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 109

Classes and Association ClassifiersClasses and Association Classifiers

Bob

Karl

Alice

Jill

Peggy

Adults

Fred

Children

Cory

Dee

Guy

Hayley

Ida

Les

Adult

name : String name : String

gender : [M, F]

Child

name : String name : String

gender : [M, F]

parents

1..2

children

0..*

Page 103: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 110

Interpreting Association EndsInterpreting Association Ends

Adult

name : String name : String

gender : [M, F]

Child

name : String name : String

gender : [M, F]

parents

1..2

children

0..*

Children Adults

Karl

Cory Dee

Ida

The ―children‖ The ―children‖ (set) of Karl(set) of KarlThe ―children‖ The ―children‖ (set) of Karl(set) of Karl

Jill

The ―parents‖ The ―parents‖ (set) of Cory(set) of CoryThe ―parents‖ The ―parents‖ (set) of Cory(set) of Cory

Karl.children->includes(Cory)

An OCL An OCL constraintconstraint An OCL An OCL constraintconstraint

Page 104: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 111

Example Metamodel: UML (simplified fragment)Example Metamodel: UML (simplified fragment)

Element

sources

1..*

targets

1..*

Directed Relationship

NamedElement

name : String

NamedElement

name : String Generalization Generalization generalizations

0..*

NamedElement

Type

types 1..*

TypedElement

Classifier

Attribute Attribute

Operation Operation

Class

attributes

0..*

operations

0..*

Feature Feature features

0..*

Classifier Classifier

PrimitivePrimitiveType

Page 105: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 112

Obj 1

[ClassA]

Obj 2

[attr. a1]

Under the Hood: How Models are StoredUnder the Hood: How Models are Stored

A

a1 : Integer

B

get_a1() : Integer

User view Model

repository view

Diagrams are just

Diagrams are just selective views of the underlying model

: Generalization

targets[1]

sources[1]

: PrimitiveType

name = “Integer”

types[1]

types[1]

: Class

name = “A”

: Attribute

name = “a1”

attributes[1]

generalizations [1]

: Class

name = “B”

: Operation

name = “get_a1”

operations[1]

NB: NB: Models are complex graphs

Page 106: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 113

Models and DiagramsModels and Diagrams Model elements can be created by:

Indirectly: by creating a new element in a diagram

Directly: by inserting it directly into the model (e.g., through a program or a model browser/explorer)

Model Repository

: Generalization

targets[1]

sources[1]

: PrimitiveType

name = “Integer”

types[1]

types[1]

: Class

name = “A”

: Attribute

name = “a1”

attributes[1]

generalizations [1]

: Class

name = “B”

: Operation

name = “get_a1”

operations[1]

A

a1 : Integer

B

get_a1() : Integer

Diagrams

(model views)

Programmatic

(API)

access

usually separated Diagrams are

usually separated from the model

Page 107: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 114

OBJECT CONSTRAINT LANGUAGE (OCL): WRITING

CONSTRAINTS (WELL-FORMEDNESS RULES) AND

QUERIES

Page 108: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 115

Example: A CommunityExample: A Community

Alice Bob

Cory Dee

Eunice Fred

Guy Hayley Ida

Jill Karl

Les

Millie Nick Orville Peggy

friend

friend friend

friend

friend

Page 109: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 116

A Corresponding Class DiagramA Corresponding Class Diagram

Adult Child+child+parent

0..*0..*

Person

+name: String+isMarried: Boolean+gender: Gender+age: Integer

+isSenior(): Boolean

+friend

0..*

0..*

+wife

+husband

0..1

0..1

Gender<<enumeration>>

+M+F

Page 110: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 117

Propositions, Predicates, and ConstraintsPropositions, Predicates, and Constraints

Proposition: A statement that is either True of False

Bob is an Adult

Les and Ida are friends

Predicates: Propositions that involve variables; e.g.:

There is at least one Adult with the name ―Bob‖

All Adults are married

Every Child has at least one Adult parent

A predicate require a range for its variables

Constraints: predicates that, by design, must evaluate to True; e.g.:

Only Adults can have Children

An Adult who is married must have a spouse

Page 111: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 118

FirstFirst--Order (Predicate) Logic(s)Order (Predicate) Logic(s)

Used to reason about predicates

Basic operators of FOL:

The usual Boolean operators

• AND ()

• OR ()

• NOT ()

Conditional:

• If <predicate-1> is True (hypothesis) then <predicate-2> (conclusion) must be True

• <predicate-1> <predicate-2>

Existential quantifier ():

• There exists at least one member of the domain such that predicate <predicate> is True

• a Dom | <predicate>

Universal quantifier ():

• For all members of the specified domain <predicate> is True

• a Dom | <predicate>

Page 112: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 119

FOL Examples and OCL EquivalentsFOL Examples and OCL Equivalents

There is at least one Adult with the name ―Bob‖

a Adult | (name(a) = ―Bob‖)

All Adults are married

a Adult | (married(a) = True)

Every Child has at least one Adult parent

c Child | (size(parents(c)) 1)

...and their OCL equivalents

exists (a:Adult| a.name = “Bob”)

forAll (a:Adult | a.isMarried)

forAll (c:Child | parents->size() >= 1)

Page 113: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 120

The Object Constraint Language (OCL)The Object Constraint Language (OCL)

An OMG standardized language for specifying constraints and queries for UML and MOF classifiers and objects

http://www.omg.org/spec/OCL/2.2/PDF

Declarative side-effect-free language

Primarily used in conjunction with MOF to specify the abstract syntax of modeling language constructs

Example: Adult Child

+child+parent

0..*0..*

>size() <= 2

context Child inv:

self.parent->size() <= 2

Page 114: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 121

OCL Basics OCL Basics –– Contexts and ConstraintsContexts and Constraints

Context: identifies the class (or object) to which the constraint (also called an invariant) applies

context Person inv: ...

Class constraints are written from the perspective of a generic member of the context class

...which means that they apply to all members of the class

((self.isMarried) and (self.gender = #M))

implies((self.wife->size() = 1) and

(self.husband->size () = 0))

Person

+name: String+isMarried: Boolean+gender: Gender+age: Integer

+isSenior(): Boolean

+wife

+husband

0..1

0..1

+friend

0..*

0..*

Page 115: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 122

OCL Basics OCL Basics –– Data Types Used in OCLData Types Used in OCL

Reuses basic UML/MOF primitive types

Boolean, Integer, String

Adds type Real

Support all common arithmetic and logic operators

Collection types

Set, OrderedSet, Bag, Sequence

Model types

Modeler-defined application-specific classes

E.g., Person, Adult, Child, Gender

OclType = the type of all types (metatype)

Useful operation on any type: allInstances()

Person.allInstances() -- returns the set of all -- instances of Person

Page 116: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 123

OCL Basics OCL Basics –– Standard Arithmetic OperatorsStandard Arithmetic Operators

<numeric-expr-1> < <numeric-expr-2>

<numeric-expr-1> > <numeric-expr-2>

<numeric-expr-1> <= <numeric-expr-2>

<numeric-expr-1> >= <numeric-expr-2>

<numeric-expr-1> + <numeric-expr-2>

<numeric-expr-1> - <numeric-expr-2>

<numeric-expr-1> * <numeric-expr-2>

<numeric-expr-1> / <numeric-expr-2>

<numeric-expr-1>.mod(<numeric-expr-2>)

...

Page 117: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 124

OCL Basics OCL Basics –– Common Logic OperatorsCommon Logic Operators

not <Boolean-expr>

<Boolean-expr-1> or <Boolean-expr-2>

<Boolean-expr-1> and <Boolean-expr-2>

<Boolean-expr-1> xor <Boolean-expr-2>

<expression-1> = <expression-2>

<expression-1> <> <expression-2>

<Boolean-expr-1> implies <Boolean-expr-1>

if <Boolean-expr-1> then <expression-2>

[else <expression-3> endif]

Page 118: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 126

OCL Basics OCL Basics –– Accessing PropertiesAccessing Properties

Classifier (and object) attributes and operations are accessed by the dot (.) operator

self.name -- returns name String

self.isSenior() -- returns True or False

self.friend -- returns a collection

-- persons who are friends

-- of “self”

Person

+name: String+isMarried: Boolean+gender: Gender+age: Integer

+isSenior(): Boolean

+wife

+husband

0..1

0..1

+friend

0..*

0..*

Page 119: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 127

OCL Basics OCL Basics –– Association/Link NavigationAssociation/Link Navigation

Association ends are accessed like all other Properties of Classifiers

OCL can navigate from a Classifier context to any outgoing association end...regardless of navigability

self.friend

self.person -- uses default naming rule for

-- unnamed ends

Unless the multiplicity is exactly 1, the result of the navigation is a collection

Person

+name: String+isMarried: Boolean+gender: Gender+age: Integer

+isSenior(): Boolean

+friend

0..*

0..*

Page 120: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 128

OCL Basics OCL Basics –– OCL Collections and Operations OCL Collections and Operations

Collections represent groups of values (e.g., Classes)

Collections can be manipulated using special collection operations

size() -- the size of the collection (Integer)

count(<value>) -- the number of occurrences of <value> (Integer)

includes(<value>) -- True if collection includes <value>

includesAll(<collection>) -- True if collection includes <collection>

isEmpty() -- True if collection is empty

notEmpty() -- True if collection is not empty

exists(<expression>) -- True if <expression> is True for at least 1 element

forAll(<expression>) -- True if <expression> is True for all elements

...

Collection

SetOrderedSet Bag Sequence

Page 121: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 129

OCL Basics OCL Basics –– Applying Operations to CollectionsApplying Operations to Collections

The application of an operation to a collection is indicated by the use of the right-arrow (->) operator

self.friend->size() -- number of friends of self

self.friend->isEmpty() -- checks if set of

-- friends is empty

Page 122: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 130

OCL Basics OCL Basics –– Universal and Existential QuantifiersUniversal and Existential Quantifiers

―exists‖ and ―forAll‖ operations are used to specify predicates over collections

exists = (first-order logic existential quantifier operator)

• self.friend->exists (f:Person | f.name = „Bob‟)

-- at least one friend must be named „Bob‟

forAll = (first-order logic universal quantifier operator)

• Person.allInstances()->forAll(p:Person| p.name <> „‟)

-- the name of a Person cannot be an empty string

Avoids confusing mathematical symbols (+ avoids need for special typesetting)

Page 123: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 131

OCL Basics OCL Basics –– Select and Collect OperationsSelect and Collect Operations

Special iteration operations for deriving useful new collections from existing ones

Select provides a subset of elements that satisfy a predicate

<collection>->select (<element> : <type> |

<expression>)

Person->select (p:Person | p.isMarried)

Collect returns a new collection of values obtained by applying an operation on all of the elements of a collection

<collection>->collect (<element> : <type> |

<expression>)

Person->collect (p:Person | p.name)

Page 124: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 132

OCL Basics OCL Basics –– Other Useful Collection OperationsOther Useful Collection Operations

For Sets, Bags, Sequences

<Coll-1>->union (<Coll-2>) -- returns the union of

-- <Coll-1> and <Coll-2>

<Coll-1>->intersection(<Coll-2>) -- returns the

-- intersection of

-- <Coll-1> and <Coll-2>

<Coll-1> - (<Coll-2>) -- returns a collection of

-- elements in <Coll-1>

-- that are not in <Coll-2>

For OrderedSets and Sequences

<Coll>->at(i) -- access element at position i

<Coll>->append(<object>) -- add <object> to end of <Coll>

<Coll>->first() -- return first element in <Coll>

<Coll>->last() -- return last element in <Coll>

Page 125: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 133

OCL Basics OCL Basics –– PrePre-- and Postand Post--ConditionsConditions

―Design by contract‖ for Operations, Receptions, and UML Behaviors

Pre-conditions: Conditions that must hold before an operation

Post-conditions: Conditions that must hold after an operation has completed

Syntax:

pre: <Boolean-expr>

post: <Boolean-expr>

Also can use <attribute>@pre in a post-condition to refer to the value of <attribute> prior to the execution of the operation

Page 126: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 134

OCL Basics OCL Basics –– Defining OperationsDefining Operations

Syntax context <operation-name>(<parameters>) : <return-

type>

[pre: <Boolean-expr>]

[post: <Boolean-expr>]

[body: <expression>] -- must evaluate to

-- a kind of <return-type>

Example

context Person::isSenior() : Boolean

pre: age >= 0

post: age = age@pre -- age is unchanged

-- after operation

-- completes

body: (age >= 65)

Page 127: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 135

Summary: OCLSummary: OCL

OCL constraints are one of the means to define well-formedness (i.e., syntactic) rules for MOF-based models

Complement class (meta)models

It is based on basic first-order logic and set theory and operates on class (and instance) diagrams

Since class diagrams deal with relationships between sets and elements of sets

Defines primarily static semantics but can also be used to specify dynamic semantics (e.g., through pre- and post- statements on operations)

Page 128: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 136

MOF Pattern: Association SpecializationMOF Pattern: Association Specialization

BankAccount BankCustomer accounts

1..*

customers

1..*

Corporate Account

Personal Account

Corporate Customer

Private Customer

owners

1..*

P-accounts

1..*

owner

1

C-accounts

1..*

NB: tightenedNB: tightened NB: tightenedNB: tightened constraintconstraint

Page 129: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 137

More Refined SpecificationMore Refined Specification

BankAccount BankCustomer accounts

1..*

customers

1..*

Corporate Account

Personal Account

Corporate Customer

Private Customer

owners

1..*

P-accounts

1..*

owner

1

C-accounts

1..*

{subsets accounts}

{subsets accounts}

{subsets customers}

{subsets customers}

{union}

/accounts

{union}

/customers

Page 130: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 138

Composition (―Black Diamond‖) AssociationsComposition (―Black Diamond‖) Associations

Implies ―ownership‖ of one element by another

i.e., An instance of Person owns an instance of String that specifies that person‘s ―name‖

Semantics: ―Deletion‖ semantics

When the owner is removed, all its owned elements are also removed with it

0..1 name

1

Person String

value

a : Person

name

:String

value = “Bran”

Page 131: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 139

Key MOF Abstraction: Names and NamespacesKey MOF Abstraction: Names and Namespaces

Names are specified by Strings

No pre-defined character set or size limit

E.g.: ―Alice‖, ―R2->D2‖, ―4 Sale‖, ―Ceлић‖, ―多音字‖, ―‖

NB: An empty name is a valid name

A namespace is a model element that owns a collection of model elements (that may be) distinguished by their names

The features (attributes, operations, etc.) of a Class

Used as a basis for specifying other MOF concepts: Package, Class, Operation, etc.

General rules (may be further constrained in a profile)

Names in a namespace are not necessarily unique (but is preferred)

• E.g. Two operations may have the same name but different parameter sets

• E.g.: an operation and an attribute of a class can have the same name

Namespaces can contain other namespaces hierarchical (qualified) names

• Use of double-colon (::) to separate names in a qualified name

• E.g.: ―System::CoolingSubsystem::ACUnit‖

Page 132: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 140

The Concept of VisibilityThe Concept of Visibility

Named elements owned by a MOF namespace have a defined visibility:

The capacity for an element to be referenced by other model elements (possibly in other namespaces)

Pre-defined visibility kinds:

public (+) – named element is visible to all elements that can access its namespace

private (-) – visible only within the namespace that owns it

protected (#) – visible only to elements in its extended namespace (i.e., its namespace and the namespaces of all specializing classifiers – for classifier type namespaces only)

• E.g., a Class attribute visible to all subclasses of that Class

package – (~) visible only to other elements in the same package

• e.g., a Class attribute visible to all elements in the same Package as the Class

Page 133: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 141

MOF PackagesMOF Packages

A Package is a means for grouping the parts of a (meta)model

Packages are (typically) not intended to model anything

Analogous to file system folders

A package is a kind of namespace

Public elements from other packages can be imported into the package namespace (analogous to ―external‖ declarations in programming)

Page 134: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 142

Package DiagramsPackage Diagrams

Show relationships (import, merge) between packages in a model

A design-time view

«modelLibrary»

UtilityClasses Kernel

ExtendedKernel

Top

«import»

«import»

«import»

«merge»

Page 135: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 143

X Y

Package Import SemanticsPackage Import Semantics

Following importing, namespace X contains the following names:

A, B, C, Y::C, E

...but not D

However, Y::C and E are not owned by X

«import» A

B +C -D

+E C

Page 136: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 146

Package MergePackage Merge

Allows selective incremental concept extension

EMOF::Reflection

Element

getMetaClass() …

Object

ElementElement

InfrastructureLibrary

«merge»

EMOF::Reflection

ElementElement

getMetaClass() …

Object

resultresult

Page 137: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 147

Package Merge SemanticsPackage Merge Semantics

A graphically-specified operation on packages and their contents

Extends definition and scope of a concept through an increment

Why not just use subclassing?

The additional specifications apply to the original concept wherever it was used

Element

Object

Element

Object

We would need to replace Element with the new ObjectElement class in all parts of the model where Element originally appeared

We would need to replace Element with the new ObjectElement class in all parts of the model where Element originally appeared

Page 138: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 148

MOF Pattern: Modular (MOF Pattern: Modular (MixinMixin) Generalizations) Generalizations

A meta-modeling pattern for adding capabilities using specialized superclasses

Each increment adds a well-defined primitive capability

To be used with extreme caution because it can lead to semantic conflicts and overgeneralization problems

• Especially if the mixin classes have associations

Property Operation Parameter

MultiplicityElement

lower : Integer

upper : UnlimitedInteger

lower : Integer

upper : UnlimitedInteger

NamedElement

name: String [0..1] name: String [0..1]

PackageableElement PackageableElement

Page 139: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 149

MetaMeta--Modeling Trap: OvergeneralizationModeling Trap: Overgeneralization

Fragment of the UML 2 metamodel (simplified):

Relationship

Dependency

Classifier

Use Case

What does it What does it mean for a Dependency to own a Use Case?

generalization Over-

generalization

Element

ownedElement 0..*

owner

0..1

Page 140: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 150

Dealing with OvergeneralizationDealing with Overgeneralization

Caused by ―abstract‖ associations

Can sometimes be avoided using association specialization (covariance) or constraints

Relationship

Element

Classifier

ownedElement 0..*

owner

0..1

ownedElement->size() = 0

Element

OwnedBy

Element

OwnedBy

Classifier

Page 141: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 151

MOF AlternativesMOF Alternatives

XMF Mosaic – Extesible Modeling Framework

http://itcentre.tvu.ac.uk/~clark/downloads.html

http://www.eis.mdx.ac.uk/staffpages/tonyclark/Papers

EMF – Eclipse Modeling Framework

http://www.eclipse.org/modeling/emf/

RDFS - Resource Description Framework Schema

http://www.w3.org/TR/rdf-schema/

Xtext – a textual metamodeling language for languages with a textual concrete syntax

http://www.eclipse.org/Xtext/

Page 142: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 152

The XMF The XMF XCoreXCore MetamodelMetamodel

Page 143: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 153

The EMF MetamodelThe EMF Metamodel

Page 144: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 154

RDFS RDFS –– An Alternative to MOFAn Alternative to MOF

Resource Description Framework Schema (RDFS)

A standardized format for knowledge (ontology) representation and interchange on the World-Wide Web

Standardized by the W3C consortium

http://www.w3.org/standards/techs/rdf

Based on simple <object-attribute-value> paradigm:

http://www.library.org/books#WarAndPeace

Leo Tolstoy

author

Resource Resource (object)

Attribute Attribute Value Value

Encoded using an XML syntaxEncoded using an XML syntax

http://www.library.org/content#WarAndPeace

publisher Doubleday Co.

content etc.

URI

Page 145: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 155

RDFS Metamodel (simplified)RDFS Metamodel (simplified)

Everything is a resource (identified by a URI)

RDFSResource

localName : String namespace : String uri : String

RDFStatement

1 predicate

subject

1 object

1 RDFSLiteral

RDFProperty RDFClass domain

0..* range

0..*

Properties can be

multiple classes

Properties can be defined independently of Resources and can be associated with multiple classes

Page 146: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 156

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Specifying Abstract Syntax

Specifying Concrete Syntax

Specifying Semantics

Case Study: UML

Model Transformations

Summary

Page 147: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 157

OMG Languages Concrete SyntaxOMG Languages Concrete Syntax

Incomplete and informally defined

No definitive rules on what is a valid syntactical construction

Abstract to concrete syntax mapping is incomplete and ambiguour

Creates difficulties in model interchange and confuses users

Fortunately, the new ―Diagram Definition‖ standard is a step towards remedying these deficiencies

Page 148: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 158

OMG‘s Data Definition StandardOMG‘s Data Definition Standard

A standard for:

1. Specifying concrete graphical syntax (Diagram Graphics = DG)

2. Interchanging model diagrams (Diagram Interchange = DI)

For defining the concrete syntax of MOF-based modeling languages

Comprises a modeling language in MOF

Support for variations

Different ways of specifying mappings of concrete syntax elements to corresponding abstract syntax elements

• Model transforms, tables, informal text...

Different ways of interchanging diagrams

• Based on what is assumed to be known by the rendering tool (e.g., UML tool versus general drawing tool)

Page 149: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 159

Model editor Rendering tool

How DD Works: UML ExampleHow DD Works: UML Example

MOF MOF

UML Metamodel

UML Metamodel

UML DI Metamodel

UML DI Metamodel

Model Model Transform

“Language”

DD DI Metamodel

DI Metamodel

DG Metamodel

DG Metamodel

Mapping

MOF MOF M3

M2

M1 :UseCase

:Group :Group

:Ellipse :Ellipse

center = {25, 15}

:Text :Text data = “mumble”

data = “mumble” bounds = {10, 25, 25, 10}

transform

:UMLShape :UMLShape

bounds = {0,0,50,30)bounds = {0,0,50,30)

:UMLLabel :UMLLabel

bounds{10, 35, 25, 10}bounds = {10, 35, 25, 10}

Page 150: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 160

DD: Elements of the DI MetamodelDD: Elements of the DI Metamodel

Page 151: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 161

Specializing DI: UML ExampleSpecializing DI: UML Example

Page 152: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 162

Mapping DI to DG: UML ExampleMapping DI to DG: UML Example

Using the OMG standard model transformation language QVTo (operational QVT)

E.g.:

Page 153: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 163

Summary: Concrete SyntaxSummary: Concrete Syntax

The use of graphically-oriented forms for many modeling languages (linear text) is one of the main areas of differentiation between programming and modeling languages

Graphics can be much more effective at communicating certain types of information than text

But, they also add complexity to the language specification

Most modeling languages are hybrids combining different both graphical and textual forms in a single language

Form should follow function – each form where it is most appropriate

Some useful technologies and methods are emerging for specifying graphical concrete syntaxes

However, we still have no proper theory of how to design such languages

What makes a concrete syntax an effective communications tool?

Page 154: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 164

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Specifying Abstract Syntax

Specifying Concrete Syntax

Specifying Semantics

Case Study: UML

Model Transformations

Summary

Page 155: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 165

On Specifying SemanticsOn Specifying Semantics

Semantics are specified using a language whose semantics are already defined

Numerous approaches to defining run-time semantics of computer languages

Informal natural language description are the most common way

Denotational, translational, operational, axiomatic

Page 156: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 166

On Specifying SemanticsOn Specifying Semantics

The ―Executable UML Foundation‖ specification provides a standard for defining semantics

Defines the dynamic semantics for a subset of standard UML concepts that have a run-time manifestation

Semantics of modeling languages can be specified as programs written using a standardized executable modeling language (operational (interpretive) approach)

The semantics of Executable UML itself are defined axiomatically

http://www.omg.org/spec/FUML/

Page 157: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 167

OMG Approach to OMG Approach to Specifying UML Specifying UML SemanticsSemantics

UML semantics hierarchy

As defined by the Executable UML Foundation proto-standard

Core structural elements (objects, links, etc.)Core structural elements (objects, links, etc.)

Foundational UML (fUML) action semanticsFoundational UML (fUML) action semantics (action executions, token flows, etc.)(action executions, token flows, etc.)

Act on (create, destroy, read, write, etc.)Act on (create, destroy, read, write, etc.)

Generic Generic UML VMUML VM

(with (with SVPs)SVPs)

SVP = Semantic Variation PointSVP = Semantic Variation Point

Map (compile) toMap (compile) to

HigherHigher--level behavioral formalisms (with SVPs)level behavioral formalisms (with SVPs)

UMLUML UMLUML statechartstatechart semanticssemantics

UMLUML UMLUML activitiesactivities

semanticssemantics

UMLUML UMLUML interactionsinteractions semanticssemantics

Action Language(s)Action Language(s) UMLUML

Action Language(s)Action Language(s)

HigherHigher--levellevel HigherHigher--levellevel UML actionUML action semanticssemantics

Page 158: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 168

Foundational UML (fUML) and Basic UML (bUML)Foundational UML (fUML) and Basic UML (bUML)

A subset of fUML actions is used as a core language (Basic UML) that is used to describe fUML itself

Foundational UML (fUML) action semanticsFoundational UML (fUML) action semantics Foundational UML (fUML) action semanticsFoundational UML (fUML) action semantics (action executions, token flows, etc.)(action executions, token flows, etc.)

Maps to Maps to (Operational(Operational Specification)Specification)

Basic UML action semantics (bUML)Basic UML action semantics (bUML) Basic UML action semantics (bUML)Basic UML action semantics (bUML)

Maps to (Axiomatic Specification)Maps to (Axiomatic Specification)

Formal mathematical model Formal mathematical model Formal mathematical model Formal mathematical model (Process Specification Language)(Process Specification Language)

Basis for a formalization of UMLBasis for a formalization of UML

Page 159: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 169

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Specifying Abstract Syntax

Specifying Concrete Syntax

Specifying Semantics

Case Study: UML

Model Transformations

Summary

Page 160: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 170

MDA Languages ArchitectureMDA Languages Architecture

MDA = OMG‘s initiative to support model-based engineering with a set of industry standards:

Core Specifications:Core Specifications:

Core Specifications:Core Specifications:

MOF 2, XMI 2.1, MOF Versioning, MOF QVT, MOF to TextMOF 2, XMI 2.1, MOF Versioning, MOF QVT, MOF to Text

UML 2 Infrastructure

UML Profiles

UML 2UML 2 CWMCWM SPEMSPEM SPEMSPEM (Ontology)(Ontology)

ODMODM

(Ontology)(Ontology) RASRAS

Page 161: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 171

UML 1: The First CutUML 1: The First Cut

Booch OMT

OOSE

etc.

The primary intent

results of analysis and

The primary intent was to facilitate

documentation of the results of analysis and

design.

Page 162: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 172

UML Roots and Evolution: UML 1UML Roots and Evolution: UML 1

MDA

UML 1.1 (First OMG Standard)

UML 1.3 (profiles) UML 1.3 (profiles)

UML 1.4 (bug fixes) UML 1.4 (bug fixes)

UML 1.5 (Action Semantics) 2003

1967

Semantic Foundations of OO ( , Goldberg, Meyer, Semantic Foundations of OO (Nygaard, Goldberg, Meyer, Stroustrup, Harel, Wirfs-Brock, Reenskaug,…)

Jacobson Harel Booch Rumbaugh

1996

Page 163: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 173

UML 1.1 (First OMG Standard)

UML 1.3 (profiles) UML 1.3 (profiles)

UML 1.4 (bug fixes) UML 1.4 (bug fixes)

UML 1.5 (Action Semantics) 2003

1967

Semantic Foundations of OO ( , Goldberg, Meyer, Semantic Foundations of OO (Nygaard, Goldberg, Meyer, Stroustrup, Harel, Wirfs-Brock, Reenskaug,…)

Jacobson Harel Booch Rumbaugh

1996

UML Roots and Evolution: UML 2UML Roots and Evolution: UML 2

2005

UML 2.0 (MDA)UML 2.0 (MDA)

UML UML 2.42.4 UML UML 2.42.4 2010

.

.

.

Page 164: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 174

UML 1 UML 1 vsvs UML 2UML 2

UML 1 was intended primarily as a design and documentation tool

Informal and semi-formal definition

Overlapping and ambiguous concepts

UML 2 is intended to support MDA

Much more formal and precise definition

• Executable UML Foundation

Opens up potential to use UML as an implementation language

UML 2 added capabilities

Highly-modular language architecture

Improved large-system modeling capability

• Interactions, collaboration (instance) structures, activities all defined recursively for scalability

More powerful language extensibility capability

Page 165: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 175

UML 2 Language ArchitectureUML 2 Language Architecture A user-selectable collection of different languages for different needs

based on a set of shared conceptual cores

Organized into user-selectable increments of increasing sophistication

Classes (L1)Classes (L1) (Structure)(Structure)

UML Infrastructure Kernel (L0)UML Infrastructure Kernel (L0)

Composite Structures Composite Structures (L1)(L1)

FlowFlow--BasedBased BehaviorBehavior CoreCore

General General BehaviorBehavior CoreCore

Actions (L1)Actions (L1) Interactions Interactions

(L1)(L1)

Use Use Cases Cases

(L1)(L1)

State State Machines Machines

(L1)(L1)

Activities Activities (L1)(L1) Components

(L2)

L2 L2 L2 L2

L2

L2

Deployments (L3)

L3

L3

L3 L3 L3 L3 L3

Page 166: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 176

UML Language Compliance LevelsUML Language Compliance Levels

4 levels of compliance (L0 – L3)

compliance(Lx) compliance (Lx-1)

Dimensions of compliance:

Abstract syntax (UML metamodel, XMI interchange)

Concrete syntax

• Optional Diagram Interchange compliance

Forms of compliance

Abstract syntax

Concrete syntax

Abstract and concrete syntax

Abstract and concrete syntax with diagram interchange

However, this architecture has been deemed as too complex for implementation and the compliance levels and the use of package merge in the definition of UML are being eliminated in UML 2.5 (due in 2012)

Page 167: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 177

UML Language Specification FormatUML Language Specification Format

Abstract Syntax

Concepts, their features, and mutual relationships

Described by a MOF metamodel + additional constraints (OCL or English)

Concrete Syntax

Notation (diagrams, text, tables, graphical representation)

UML concrete syntax definition is incomplete and informally defined

XML-based Interchange format (XMI)

Language Semantics

The meaning of UML models and the concepts used to express them

English (+ fUML model + mathematical model)

Page 168: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 178

UML Abstract Syntax

Page 169: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 179

New Approach to the UML MetamodelNew Approach to the UML Metamodel

In UML 2, a more incremental approach was used to define the abstract syntax (compared to UML 1)

Based on a core of fine-grained abstract concepts (e.g., namespace, multiplicity, redefinition)

More complex concepts derived using mixin-based composition of core concepts and package merge

More refined semantics through the use of association specialization

Enables:

Cleaner definition of core semantics (concepts are isolated from each other)

More flexible definition of complex concepts

Simpler evolution and extension

Page 170: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 180

The Root of the UML MetamodelThe Root of the UML Metamodel

Represents the Represents the generalization (union) generalization (union)

compositions between compositions between conceptsconcepts

Represents the Represents the generalization (union) generalization (union) of all varieties of of all varieties of compositions between compositions between conceptsconcepts

Page 171: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 181

The Namespaces MetamodelThe Namespaces Metamodel

Introduces capability Introduces capability Introduces capability Introduces capability to be part of a to be part of a packagepackage

Page 172: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 182

Adding Namespace RelationshipsAdding Namespace Relationships

Page 173: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 183

Types MetamodelTypes Metamodel

NB: typed elements may not actually have a type declared (lower bound of TypedElement::type = 0)

To support incomplete models

Page 174: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 184

Packages MetamodelPackages Metamodel

Page 175: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 185

ConstraintsConstraints

Captures some semantics for elements of a namespace

Expressed in either formal or natural language

E.g., Object Constraint Language (OCL), English, Australian

Notation choices:

Stack

size : Integer size : Integer {size >= 0}

IN LINE

Stack

size : Integersize : Integer

{size >= {size >= 0}

ATTACHED NOTE

Page 176: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 186

Constraints MetamodelConstraints Metamodel

ValueSpecification: modeling element that contains an expression which evaluates to a Boolean value (true/false)

The namespace can be a Class, Package, Interface, etc.

Page 177: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 187

Core Structural Concepts: ValuesCore Structural Concepts: Values

Value: universal, unique, and unchanging

Numbers, characters, strings

Represented by a symbol (e.g., 7, VII, ―a‖, ―fubar‖)

Includes object identifiers (―InstanceValue‖)

Represented by ValueSpecification in the UML metamodel

Page 178: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 188

Core Structural Concepts: ObjectsCore Structural Concepts: Objects

―Value containers‖: a (physical) space for storing values

Can be created and destroyed dynamically

Limited to storing only values conforming to a given type

The stored value may be changed (e.g., variables, attributes)

Multiple forms in UML: variables, attribute slots, objects

Object: a complex value container with a unique identity conforming to a Class type

May own attribute slots (containers for attribute values)

May be capable of performing behaviours (operations, etc.)

Identity does not change during its lifecycle

...but its type could change over type (type reclassification)

Page 179: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 189

Specifying Instances in UMLSpecifying Instances in UML

InstanceSpecification: a generic facility for modeling objects and other things that occupy memory space

The metamodel

Page 180: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 190

Multiplicity ConceptMultiplicity Concept

For specifying usages that are collections

Attributes, association ends, parameters, etc.

Can specify ranges (upper and lower bounds)

0 = absence of elements

* (or [0..*]) = open-ended upper bound

Adult

name : String [0..*]

Child

name : String [0..*]

parent

1..2

child

0..*

MultiplicityMultiplicityMultiplicityMultiplicity

MultiplicityMultiplicityMultiplicityMultiplicity

MultiplicityMultiplicityMultiplicityMultiplicity

MultiplicityMultiplicityMultiplicityMultiplicity

Page 181: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 191

Multiplicity ModifiersMultiplicity Modifiers

{unique} = no two elements of the collection can have the same value

Default value: true

{nonunique} if false

{ordered} = the elements in the collection are ordered in some appropriate manner ( an ordered collection)

Default value: false = {unordered}

Adult

name : String [0..*]

Child

name : String [0..*]

parent

1..2

child

0..*

{unique,

ordered} Multiplicity Multiplicity Multiplicity Multiplicity modifiersmodifiers

Page 182: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 192

Multiplicities MetamodelMultiplicities Metamodel

Page 183: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 193

The UML Concept of ClassifierThe UML Concept of Classifier

A classifier is a specification of a collection of entities (things, concepts, etc.) that

1. Share a set of characteristics (features) and which

2. Can be classified (divided) into sub-collections according to the nature of some of their characteristics

E.g., people can be classified based on their gender into men and women

. . . or, they may be classified according to their age into adults and children

Kinds of Classifiers in UML:

Classes, Associations, AssociationClasses, DataTypes, Enumerations, Interfaces, Behaviors (Activities, Interactions, StateMachines), Signals, UseCases, Collaborations, Components, Nodes, etc.

Page 184: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 194

UML Classifier ConceptUML Classifier Concept

Introduces concepts that can be:

Classified based on the nature of their features

Generalized/specialized

Page 185: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 195

Redefinition in UMLRedefinition in UML Introduces capability Introduces capability to be redefined (in a to be redefined (in a Introduces capability Introduces capability to be redefined (in a to be redefined (in a subsub--classifier)classifier)

Page 186: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 196

Classifier FeaturesClassifier Features

Two basic kinds:

Structural features (e.g., attributes, associations)

Behavioural features (e.g., operations, receptions)

Structural features are type usages and have:

Multiplicity

Visibility

Scope [static(classifier), instance]

• Static features are singletons and apply to the classifier as a whole rather than individual instances

Behavioural features have

Visibility and scope

Page 187: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 197

Features MetamodelFeatures Metamodel

Page 188: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 198

Class and Association MetamodelClass and Association Metamodel

Page 189: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 201

UML Concrete Syntax

Page 190: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 202

UML Concrete Syntax: Diagram TypesUML Concrete Syntax: Diagram Types

UML Diagram UML Diagram

Class

Diagram

Package

Diagram

Composite

Structure

Collaboration Collaboration

Diagram

Deployment

Diagram

Instance

Diagram Statechart

Diagram

UseCase

Diagram

Interaction

Diagram

Activity

Diagram

Structure

Diagram

Behavior

Diagram

Sequence Sequence

Diagram

Interaction Interaction

Overview

Communication Communication

Diagram

Timing Timing

Diagram

Profile

Diagram

Page 191: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 203

DIAGRAM CONTENTS AREA

[<diagramKind>] <diagramName> [<parameters>]

UML General UML General Diagram FormatDiagram Format

An optional structured form for UML diagrams

act

class

cmp

dep

sd

pkg

stm

uc

HEADER

pkgpkg TopPkgDiagramTopPkgDiagram

PkgAPkgA PkgBPkgB «import»«import»

Page 192: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 204

CONTENTS

diagramKind [elementType] elementName [diagramName]

SysML Diagram FormatSysML Diagram Format

Simpler and more systematic approach than UML All diagrams have a common mandatory format

act

bdd

ibd

pkg

par

req

sd

stm

uc

HEADER

activity

block

package

...

pkgpkg [package] Top[package] Top

PkgAPkgA PkgBPkgB «import»«import»

Page 193: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 205

SysML Diagram TypesSysML Diagram Types

Some UML diagrams were modified, others omitted, and new SysML-specific diagrams added

SysML Diagram

RequirementRequirement RequirementRequirement

DiagramDiagram

Statechart

Diagram

UseCase

Diagram

Sequence

Diagram

ActivityActivity

DiagramDiagram

Structure

Diagram

Behavior

Diagram

BlockBlock

DefinitionDefinition

Package

Diagram

ParametricParametric

DiagramDiagram

Internal BlockInternal Block Internal BlockInternal Block

DiagramDiagram

Page 194: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 206

UML Semantics

Page 195: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 207

UML Model of ComputationUML Model of Computation

Object oriented

All behavior stems from (active) objects

Distributed

Multiple sites of execution (―localities‖)

Concurrent

Active objects multiple threads of execution

Heterogeneous causality model

Event driven at the highest level

Data and control flow driven at more detailed levels

Heterogeneous interaction model

Synchronous, asynchronous, mixed

Page 196: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 208

Behavioral Semantic Base

UML UML RunRun--Time (Dynamic) Semantics ArchitectureTime (Dynamic) Semantics Architecture

Structural Semantic Base (Objects)

ActionsActions

InterInter--object object CommsComms Object ExistenceObject Existence

. . .. . . ActivitiesActivities StateState

MachinesMachines InteractionsInteractions

FlowFlow--Based Behavior SemanticsBased Behavior Semantics

Page 197: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 209

UML Model of Causality (How Things Happen)UML Model of Causality (How Things Happen)

A discrete event-driven model of computation

Network of communicating objects

All behaviour stems from objects

obj1:C1

s1

s2

obj2:C2

obj3:C1

s1

s2

act1

act2

a1:A1

a2:A2

obj1:C1

s1s1

s2

obj2:C2

obj3:C1

s1

s2s2

act1

act2

obj1:C1

s1

s2s2

obj2:C2

obj3:C1

s1

s2s2

act1

act2

obj1:C1

s1

s2s2

obj2:C2

obj3:C1

s1

s2s2

act1act1

act2act2

obj1:C1

s1

s2s2

obj2:C2

obj3:C1

s1s1

s2

act1

act2

Page 198: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 211

Basic Structural ElementsBasic Structural Elements Values

Universal, unique, constant

E.g. Numbers, characters, object identifiers (―instance value‖)

―Cells‖ (Slots/Variables)

Container for values or objects

Can be created and destroyed dynamically

Constrained by a type

Have identity (independent of contents)

Objects (Instances)

Containers of slots (corresponding to structural features)

Just a special kind of cell

Links

Tuples of object identifiers

May have identity (i.e., some links are objects)

Can be created and destroyed dynamically

Page 199: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 212

Classifier Classifier Feature Feature feature

0..*

0..* Class Class

Activity StateMachine StateMachine Interaction OpaqueBehavior OpaqueBehavior

Relationship Between Structure and BehaviourRelationship Between Structure and Behaviour

From the UML metamodel:

Actor

Class

Collaboration Collaboration

UseCase

For flow-based For flow-based behaviours

For event-driven For event-driven behaviours

For event-driven For event-driven system behaviours

Because:

―execution‖

Because: when

executed, a special

―execution‖ object is created

Behavior

owned

Behavior

0..*

0..1

context

Page 200: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 213

Classifier Behaviours Classifier Behaviours vs.Methodsvs.Methods

Methods: Intended primarily for passive objects

Can be synchronous (for operations) or asynchronous (for receptions)

Classifier behaviour: Intended primarily for active objects

Executed when the object is created

Behavior

owned

Behavior

0..*

classifier

Behavior 0..1

0..1

0..* method

Behavioral Behavioral

Feature

specification 0..1

Operation Reception Reception

Parameter Parameter

0..*

0..1

0..*

0..1 0..1

context

Page 201: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 214

Active Object DefinitionActive Object Definition

Active object definition:

An active object is an object that, as a direct consequence of its creation, commences to execute its classifier behavior, and does not cease until either the complete behavior is executed or the object is terminated by some external object.

Also:

The points at which an active object responds to [messages received] from other objects is determined solely by the behavior specification of the active object...

AnActiveClass

Parallel lines

passive classes

Parallel lines used to distinguish from passive classes

Page 202: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 215

Passive vs. Active ObjectsPassive vs. Active Objects

Passive objects respond whenever an operation (or reception) of theirs is invoked

NB: invocations may be concurrent conflicts possible!

Active objects run concurrently and respond only when they execute a ―receive‖ action

obj:C

setA(a:Integer) getA() : Integer

a1 a1: a1 a2:

setA(1) getA()

active:A

a1 a1: a1 a2:

reqB() reqA()

reqA reqB

Message queue Event selection based on chosen scheduling policy

Event selection based on chosen scheduling policy

Page 203: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 216

RunRun--ToTo--Completion (RTC) SemanticsCompletion (RTC) Semantics

Any messages arriving between successive ―receive‖ actions are queued and only considered for handling on the next ―receive‖ action

Simple ―one thing at a time‖ approach

Avoids concurrency conflicts

Message queue

ReceiveReceive

. . .

Receive

reqA

Receive

. . .. . .

Receive

reqB reqC

Receive

. . .

ReceiveReceive

reqC

Page 204: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 217

The Problem with RTCThe Problem with RTC

Message (event) priority: in some systems (e.g., real-time systems) messages may be assigned different priorities

To differentiate important (high priority) events from those that are less so and to give them priority handling (e.g., interrupting handling of a low priority message)

Priority inversion: The situation that occurs when a high priority message has to wait for a low priority message

The RTC approach is susceptible to priority inversion

But, it is limited to situations where the high-priority and low-priority events are being handled by the same object (rather than the system as a whole)

Page 205: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 218

Active1 Active2

RTC SemanticsRTC Semantics

If a high priority event arrives for an object that is ready to receive it, the processing of any low priority events by other active objects can be interrupted

hi

hi

lo

(queue

d)

Handling of low

event is processed

Handling of low priority event suspended while high priority event is processed

Processing of queued high priority event can commence at this

Processing of queued high priority event can commence at this point

Page 206: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 219

UML Communications TypesUML Communications Types

Synchronous communications: (Call and wait)

Calling an operation synchronously

Asynchronous communications: (Send and continue)

Sending a signal to a reception

Asynchronous call of an operation (any replies discarded)

Object1 Object2

send sigX()

sigX method

executing

Asynchronous

Communications

Object1 Object2

call opX()

opX method

executing

Synchronous

Communications

reply

Page 207: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 220

Purpose of UML ActionsPurpose of UML Actions

For modelling fine-grained behavioural phenomena which manipulates and accesses UML entities (objects, links, attributes, operations, etc.)

E.g. create link, write attribute, destroy object

A kind of UML ―assembler‖

The UML standard defines:

A set of actions and their semantics (i.e., what happens when the actions are executed)

A method for combining actions to construct more complex behaviours

The standard does not define:

A concrete syntax (notation) for individual kinds of actions

Proposal exists for a concrete semantics for UML Actions

Page 208: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 221

Categories of UML ActionsCategories of UML Actions

Capabilities covered

Communication actions (send, call, receive,…)

Primitive function action

Object actions (create, destroy, reclassify,start,…)

Structural feature actions (read, write, clear,…)

Link actions (create, destroy, read, write,…)

Variable actions (read, write, clear,…)

Exception action (raise)

Capabilities not covered

Standard control constructs (IF, LOOP, etc. – handled through Activities)

Input-output

Computations of any kind (arithmetic, Boolean logic, higher-level functions)

Page 209: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 222

a1:TestIdentityAction result : Boolean first:

second:

Action Specification (a design-time specification)

a1[i]:TestIdentity

ActionExecution

first: result : Boolean

second:

Action Execution (a run-time concept)

object1:C1

object2:C1

false

(value)

NB: each time action a1 needs to be executed, a new action execution is created

Output PinOutput Pin Output PinOutput Pin Input PinInput Pin Input PinInput Pin

Action Specifications and Action ExecutionsAction Specifications and Action Executions

Page 210: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 223

a1: o1: T3

i1:T1

i2:T2

a2: i1:T3

a3: o1: T3 i2:T3

Data flow MoC: output to input connections

Control flow MoC: identifying successor actions

Contention (a2 and a3)

a1: o1: T3

i1:T1

i2:T2

a2: i1:T3

a3: o1: T3 i2:T3

Data replication

a1: i1:T1

i2:T2

a4:

a5: o1: T3

a3: i1:T3 a2: o1: T3

Combining ActionsCombining Actions

Page 211: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 224

Execution order can be modeled as an exchange of data/control ―tokens‖ between nodes

a1x: i1:T1

i2:T2

a4x:

a5x: o1: T3

a3x: i1:T3 a2x: o1: T3 a1x:a1x:

aa44x:x:

a5x:a5x:

a3x:a3x: a2x:a2x:

General execution rules:

All tokens have to be available before actions execute

Tokens are offered only after action execution completes

Controlling Execution: Token PassingControlling Execution: Token Passing

Page 212: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 225

Summary: UML SemanticsSummary: UML Semantics

The UML model of computation is:

Structure dominant

Distributed

Concurrent

Event driven (at the highest level)

Data and control flow driven (at finer grained levels)

Supports different interaction models

The core part of the UML semantics is defined formally

Provides an opportunity for automated formal analyses

Page 213: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 226

UML Extensibility Mechanism -

Profiles

Page 214: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 227

UML as a Platform for DSMLsUML as a Platform for DSMLs

DSML = Domain-Specific Modeling Language

Designed as a ―family of modeling languages‖

Contains a set of semantic variation points (SVPs) where the full semantics are either unspecified or ambiguous

SVP examples:

• Precise type compatibility rules

• Communications properties of communication links (delivery semantics, reliability, etc.)

• Multi-tasking scheduling policies

Enables domain-specific customization

Open to both extension (―heavyweight‖ extension) and refinement (―lightweight‖ extension)

Page 215: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 228

Example: Adding a Semaphore Concept to UMLExample: Adding a Semaphore Concept to UML

Semaphore semantics:

A specialized object that limits the number of concurrent accesses in a multithreaded environment. When that limit is reached, subsequent accesses are suspended until one of the accessing threads releases the semaphore, at which point the earliest suspended access is given access.

What is required is a special kind of object

Has all the general characteristics of UML objects

…but adds refinements

Page 216: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 229

Example: The Semaphore StereotypeExample: The Semaphore Stereotype

Design choice: Refine the UML Class concept by

―Attaching‖ semaphore semantics

• Done informally as part of the stereotype definition

Adding constraints that capture semaphore semantics

• E.g., when the maximum number of concurrent accesses is reached, subsequent access requests are queued in FIFO order

Adding characteristic attributes (e.g., concurrency limit)

Adding characteristic operations (getSemaphore (), releaseSemaphore ())

Create a new ―subclass‖ of the original metaclass with the above refinements

For technical reasons, this is done using special mechanisms instead of MOF Generalization (see slide Why are Stereotypes Needed?)

Page 217: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 230

Example: Graphical Definition of the StereotypeExample: Graphical Definition of the Stereotype

«metaclass»

UML::Class

«stereotype»

Semaphore

limit : Integer

getSema : Operation

relSema : Operation

active->size()

<= limit limit <= MAXlimit

―Extension‖

Constraints

Special icon(Optional)Special icon (Optional)

Page 218: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 231

Example: Applying the StereotypeExample: Applying the Stereotype

«semaphore»

limit = 1

getSema = get

relSema = release

Object

print()

BinarySem

get ( )

release ( )

SomeOtherClass «semaphore»

DijkstraSem

p ( )

v ( )

«semaphore»

limit = MAXlimit

getSema = p

relSema = v

«semaphore» BinarySem

Page 219: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 232

The Semantics of Stereotype ApplicationThe Semantics of Stereotype Application

BinarySem

get ( )

release ( )

«semaphore»

BinarySem

get ( )

release ( )

«semaphore»

limit = 1

getSema = get

relSema = release

:Class

name = “BinarySem”

:Operation

name = “get”

:Operation

name = “release”

:Class

name = “BinarySem”

:Operation

name = “get”

:Operation

name = “release”

«semaphore»

limit = 1

getSema = get

relSema = release

NB: attaching a stereotype does

original!

NB: attaching a stereotype does not change the original!

Page 220: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 233

Stereotype Stereotype Representation OptionsRepresentation Options

«semaphore»

MySema

(a)

MySema

(b)

MySema

(c)

Page 221: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 234

Why are Stereotypes Needed?Why are Stereotypes Needed?

Why not simply create a new metaclass?

Semaphore

UML::

Class

Rationale:

1. Not all modeling tools support meta-modeling need to define (M2) extensions using (M1) models

2. Need for special semantics for the extensions:

– multiple extensions for a single stereotype

– extension of abstract classes (applicable to all subclasses)

MOF

generalization

Page 222: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 235

The MOF Semantics of UML ExtensionThe MOF Semantics of UML Extension

How a stereotype is attached to its base class within a model repository:

UML::Class

: MOF::Class

“Base” metaclass

base_Class

extension_Semaphore

Semaphore

: MOF::Stereotype

Stereotype

1

0..1

Association ends naming convention:

base_<base-class-name>

extension_<stereotype-name>

Required for writing correct OCL constraints for stereotypes

Page 223: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 236

Example: OCL Constraint for a StereotypeExample: OCL Constraint for a Stereotype

Semaphore constraint: the base Class must have an owned ordered attribute called ―msgQ‖ of type Message

context Semaphore inv: self.base_Class.ownedAttribute-> exists (a | (a.name = „msgQ‟) and (a.type->notEmpty()) and (a.type = Message) and (a.isOrdered) and (a.upperValue = self.limit))

UML::Class

: MOF::Class

“Base” metaclass

base_Class

extension_Semaphore

Semaphore

: MOF::Stereotype

Stereotype

1

0..1

Page 224: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 237

Adding New MetaAdding New Meta--AssociationsAssociations

This was not possible in UML 1.x profiles

Meta-associations represent semantic relationships between modeling concepts

New meta-associations create new semantic relationships

Possibility that some tools will not be able to handle such additions

UML 2.0 capability added via stereotype attribute types:

To be used with care!

«metaclass»

UML::Class

«stereotype»

Semaphore

msgQ : Message [0..*]

Creates an association

exist in UML

Creates an association between Class and Message that does not exist in UML

Page 225: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 238

UML ProfilesUML Profiles

Profile: A special kind of package containing stereotypes and model libraries that, in conjunction with the UML metamodel, define a group of domain-specific concepts and relationships

The profile mechanism is also available in MOF where it can be used for other MOF-based languages

Profiles can be used for two different purposes:

To define a domain-specific modeling language

To define a domain-specific viewpoint (cast profiles)

Page 226: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 239

ReRe--Casting Models Using ProfilesCasting Models Using Profiles

A profile can be dynamically applied or unapplied to a given model

Without changing the original model

Allows a model to be interpreted from the perspective of a specific domain

Example: viewing a UML model fragment as a queueing network

user1

user2

DBase

unapplyunapply

profileprofile

user1

user2

DBase

«client»

user1

«client»

user2

«server»

DBase

serviceRate = . . .

arrivalRate = . . .

arrivalRate = . . .

applyapply

profileprofile

Page 227: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 240

MultiMulti--Base StereotypesBase Stereotypes

A domain concept may be a specialization of more than one base language concept

SemCollaboration

client1

client2

«semaphore»

Sem

«stereotype»

Semaphore

«metaclass»

UML::

ConnectableElement

«metaclass»

UML::

Class

NB: stereotyping an NB: stereotyping an abstract class

NB: disjunctive semantics NB: disjunctive semantics (unlike generalization)

Page 228: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 241

Analysis with Cast ProfilesAnalysis with Cast Profiles

E.g., recast a model as a queueing network model

ModelingModeling

ToolTool

55 55

33..11 33..11

44 44

Model AnalysisModel Analysis

ToolTool

M2M Transform

m

Inverse M2M Transform Inverse M2M Transform

22..55 22..55

QoS annotations QoS annotations

Page 229: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 242

―Required‖ Extensions―Required‖ Extensions

An extension can be marked as ―required‖

Implies that every instance of the base class will be stereotyped by that stereotype

• Used by modeling tools to autogenerate the stereotype instances

Facilitates working in a DSML context by avoiding manual stereotyping for every case

E.g., modeling Java

«metaclass»

UML::Class

«stereotype»

JavaClass

{required}

Page 230: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 243

Strict Profile ApplicationStrict Profile Application

A strict application of a profile will hide from view all model elements that do not have a corresponding stereotype in that profile

Convenient for generating views

Strictness is a characteristic of the profile application and not of the profile itself

Any given profile can be applied either way

Page 231: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 244

Metamodel Subsetting with Profiles (1)Metamodel Subsetting with Profiles (1)

It is often useful to remove segments of the full UML metamodel resulting in a minimal DSML definition

NB: Different mechanism from strict profile application – the hiding is part of the profile definition and cannot be applied selectively

The UML 2.1 profile mechanism adds controls that define which parts of the metamodel are used

Based on refinement of the package import and element import capabilities of UML

Page 232: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 245

Metamodel Subsetting with Profiles (Metamodel Subsetting with Profiles (22))

Case 1: Metamodel Reference

All elements of the referenced MOF package (PackageX) are visible (but not the elements of PackageY)

These elements can also serve as the base metaclasses for stereotypes in MyProfile

MetamodelZMetamodelZ

PackageXPackageX PackageYPackageY «merge» «profile» «profile»

MYProfileMYProfile «reference»

Case 2: Explicit Metaclass Reference – Metaclass Q is visible and can serve as a base metaclass for stereotypes in

MyProfile

MetamodelZMetamodelZ

PackageXPackageX

QQ «profile» «profile»

MYProfileMYProfile «reference»

NB: Care must be

referenced

NB: Care must be taken to ensure that all prerequisite parts for Q (superclasses, merge increments, etc.) are also referenced

Page 233: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 246

Metamodel Subsetting with Profiles (Metamodel Subsetting with Profiles (33))

Case 3: Implicit metaclass reference

Metaclass M is visible

«profile»«profile» MyProfileMyProfile

«stereotype»«stereotype»

SS

«metaclass»«metaclass»

MetamodelZ::MMetamodelZ::M

MetamodelZMetamodelZ

MM

PP

QQ

Page 234: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 249

The UML Profile MetamodelThe UML Profile Metamodel

Page 235: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 250

Guidelines for Defining ProfilesGuidelines for Defining Profiles

Always define a pure domain model (using MOF) first and the profile elements second

Allows separation of two different concerns:

• What are the right concepts and how are they related?

• How do the domain-specific concepts map to corresponding UML concepts?

Mixing these two concerns often leads to inadequate profiles

For each domain concept, find the UML concept(s) that most closely match and define the appropriate stereotype

If no matching UML concept can be found, a UML profile is probably unsuitable for that DSML

Fortunately, many of the UML concepts are quite general (object, association) and can easily be mapped to domain-specific concepts

Page 236: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 251

Matching Stereotypes to MetaclassesMatching Stereotypes to Metaclasses

A suitable base metaclass implies the following:

Semantic proximity

• The domain concept should be a special case of the UML concept

No conflicting well-formedness rules (OCL constraints)

Presence of required characteristics and (meta)attributes

• e.g., multiplicity for domain concepts that represent collections

• New attributes can always be added but should not conflict with existing ones

No inappropriate or conflicting characteristics or (meta)attributes

• Attributes that are semantically unrelated to the domain concept

• These can sometimes be eliminated by suitable constraints (e.g., forcing multiplicity to always have a value of 1 or 0)

Presence of appropriate meta-associations

• It is possible to define new meta-associations

No inappropriate or confliciting meta-associations

• These too can be eliminated sometimes by constraints

Page 237: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 252

Beware of Syntactic Matches!Beware of Syntactic Matches!

Avoid seductive appeal of a syntactic match

In particular, do not use things that model M1 entities to capture M0 elements and vice versa

• Example: using packages to represent groupings of run-time entities

• Example: using connector and part structures to capture design time dependencies (e.g., requirements dependencies)

This may confuse both tools and users

Page 238: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 253

Catalog of Adopted OMG ProfilesCatalog of Adopted OMG Profiles

UML Profile for CORBA

UML Profile for CORBA Component Model (CCM)

UML Profile for Enterprise Application Integration (EAI)

UML Profile for Enterprise Distributed Object Computing (EDOC)

UML Profile for Modeling QoS and Fault Tolerance Characteristics and Mechanisms

UML Profile for Schedulability, Performance, and Time

UML Profile for System on a Chip (SoC)

UML Profile for Systems Engineering (SysML)

UML Testing Profile

UML Profile for Modeling and Analysis of Real-Time and Embedded Systems (MARTE)

UML Profile for DoDAF/MoDAF (UPDM)

Page 239: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 254

BibliographyBibliography

OMG UML Profiles specifications

http://www.omg.org/technology/documents/profile_catalog.htm

Page 240: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 255

Tutorial OutlineTutorial Outline

Models: What and Why

Modeling Language Design

Modeling Language Specification

Model Transformations

Summary

Page 241: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 256

Model Transformations: PurposeModel Transformations: Purpose

Generating a new model from a source model—according to formally defined rules—to:

1. Extract an interesting subset of the source model (Query)

• Example: Find all classes that have multiple parents

2. Generate a new model, based on a different metamodel, that is ―equivalent‖ to the source model (Transformation)

• Example: Create a queueing network model of a UML model to facilitate performance analysis

• Example: UML to Java transformation for code generation

• Definition of ―equivalence‖ depends on the particular case

3. Represent the source model from a particular viewpoint (View)

• In effect, just a special case of Transformation

Page 242: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 257

M1

M2 Transformation

MM1 to MM2

Transformation

Rules

A Basic Representation of Model TransformationA Basic Representation of Model Transformation

Source to target mapping based on pre-defined transformation rules

Conceptually similar to source code compilation

model2model2

: MM2: MM2

model1 model1

: MM1: MM1

Transformation

Transformation

Mapping

MetamodelMetamodel MetamodelMetamodel

MM1MM1

MetamodelMetamodel MetamodelMetamodel

MM2MM2

Can be either a process or an object Can be either a process or an object

Page 243: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 258

(1) Source element

to target pattern

Model Transformations: StylesModel Transformations: Styles

(2) Source pattern

to target element

(3) Source pattern

to target pattern

Page 244: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 259

Features of Model TransformationsFeatures of Model Transformations

Based on classification of Czarnecki and Helsen*

*K. Czarnecki and S. Helsen, “Feature-based survey of model transformation approaches”,

IBM Systems Journal, vol. 45, no.3, 2006

Model Transformation

Transformation Rules

Rule Application

Control

Rule Organization

Source/Target Relationship

Incrementality

Directionality

Tracing

Page 245: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 260

Model Transformation FeaturesModel Transformation Features

Transformation rules – the rules for the transformation

Rule application control – controlling where (location) and when (scheduling) a rule applies

Rule organization – packaging and reuse of rules

Source-target relationship – are source and target the same model or different ones?

Incrementality – incremental change support

Directionality – of transformations (one way or multiple directions)

Tracing – retaining trace links between source and target

Page 246: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 261

The Traditional Template ApproachThe Traditional Template Approach

A basic ―element-to-pattern‖ style

Generate a target pattern for each element of the source model

Example (S. Mellor: ―archetype‖ language that generates a Java class):

.for each object in O_OBJ

public class ${object.name} extends StateMachine private StateMachineState currentState; .select many attributes related by object->O_ATTR[R_105] .for each attribute in attributes private ${attribute.implType} ${attribute.name}; .end for . . . .select many signals related by object->SM_SM[R301]->SM_EVT[R303] .for each signal in signals protected void ${signal.name} () throws ooadException; . . . .end for } .emit to file ${object.name}.java .end for

Open source example: Jave Emitter Templates (JET) in Eclipse

Page 247: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 262

Some Drawbacks of the Template ApproachSome Drawbacks of the Template Approach

Primarily intended for model-to-code transforms

Optimized for working with strings

Model-to-model transforms possible but may be difficult to specify

Cons:

E.g., no dedicated support for a system-level optimization pass

Unidirectional: no built-in support for inverse mapping

Localized perspective: no support for incremental transformation (―recompile the world‖ for every change, regardless of scope)

Serialized transformation process (like Cfront): No ability to exploit application level knowledge for optimization

Page 248: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 263

MDA Transformation StandardsMDA Transformation Standards

MOF to XMI

MOF to JMI

MOF 2 Queries/Views/Transformations

MOF to Text

Page 249: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 264

QVT BasicsQVT Basics

Three types of transformations defined:

Core

Relations

Operational Mappings

The first two forms are declarative the third is imperative (procedural)

Core is a ―minimal‖ form based on minor extensions to OCL and EMOF

Relations is more user-friendly but may be less efficient

The standard defines a formal mapping from Relations to Core

Operational style provides more flexibility but is more complex

All allow invocation of external (―black box‖) transforms

Page 250: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 265

QVT Metamodel Structure (simplified)QVT Metamodel Structure (simplified)

EMOF «import»

Essential Essential

OCL

Imperative Imperative

OCL

«import»

Operational Operational

QVT

«import»

«import»

Mapping Mapping

Relations

QVT

«import»

Core

QVT

«import»

Common

«import» «import»

Page 251: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 266

M1

M2

Transform Transform

[MM1-MM2]

model2model2

: MM2: MM2

model1 model1

: MM1: MM1

MetamodelMetamodel MetamodelMetamodel

MM1MM1

MetamodelMetamodel MetamodelMetamodel

MM2MM2

A Generalized Model of QVT Model TransformationsA Generalized Model of QVT Model Transformations

Transformations can be viewed as an instantiable collection of relations between metamodel patterns

relationshiprelationship relationshiprelationship relationshiprelationship relationshiprelationship RelationRelationii

aTransform aTransform

: Transform

relationshiprelationship relationshiprelationship relationshiprelationship relationshiprelationship ri:Relationri:Relationii

Trace Trace

Page 252: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 267

Relations and TransformationsRelations and Transformations

A relation specifies a matching between two (or more) model patterns in respective models

A pattern (domain) in a relation can be designated as – ―checkonly‖ – only detects and flags violations of relation

– ―enforced‖ – modifies corresponding model to assure relation holds

A relation may invoke (depend on) other relations

A transformation consists of one or more ―top-level‖ relations that must hold

– …and a set of relations invoked (transitively) by top-level relations

Page 253: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 268

Class2Table

Relational Transforms: Graphical SyntaxRelational Transforms: Graphical Syntax

Only practical for binary relations

cn.notEmpty ()

when

Property2Column (c, t)

where

c:Class

name = cn

«domain»

p : Property

name = pn

t : Table

name = cn+’_tid’

«domain»

col : Column

name = pn

C E

u1 : UML r1 : RDBMS

Page 254: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 269

Relational Transforms: Textual SyntaxRelational Transforms: Textual Syntax

Equivalent textual specification:

relation Class2Table {

checkonly domain u1:UML c:Class {

name = cn, p:Property {name = pn}}

enforce domain r1:RDBMS t:table {

name = cn + „_tid‟,

col:Column {name = pn }}

when { cn.notEmpty() }

where { Property2Column (c, t) }}

Any number of domains (patterns) can be included in a relation

Page 255: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 270

Transformation Relations as ObjectsTransformation Relations as Objects

Model transformation can be viewed as enforcement of pre-defined formal relations between two or more models

This can be achieved by instantiating a set of ―relation‖ objects (traces) that enable continuous transformation

If one model changes, trace objects react to ensure that the declared relations between models always hold (for enforced domains)

Only the necessary changes are made incremental change model

Page 256: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 271

Example: UML to MOF Model TransformExample: UML to MOF Model Transform

Translate a UML-based metamodel into a proper MOF metamodel

e.g., MOF does not support association classes

Page 257: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 272

Example: UML Metamodel (Simplified Fragment)Example: UML Metamodel (Simplified Fragment)

Page 258: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 273

Example: MOF Metamodel (Simplified Fragment)Example: MOF Metamodel (Simplified Fragment)

Page 259: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 274

«domain»

«domain»

C E

u : UML m : MOF

UMLAssocClass2MOF

Example: Relationship DefinitionExample: Relationship Definition

Page 260: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 275

Alternative: Operational Mappings ApproachAlternative: Operational Mappings Approach

A ―how‖ (vs ―what‖) approach to transformation

Unidirectional: source and target clearly identified

However: support for incremental transforms

• Uses concept of ―trace‖ objects that incarnate a transformation instance

Provides explicit control over the entire transformation process

E.g., can specify sub-transformations that can be executed in parallel

Extends OCL with imperative statements and side-effects

E.g.: assignment statement, imperative ‖if-then-else‖, loops, etc.

Used to specify transformation procedure

Includes a ―standard library‖ of OCL operations

Page 261: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 276

Operational Mapping: BasicsOperational Mapping: Basics

Some conceptual overlap with Relations

Source is always ―checkonly‖ and target is always ―enforced‖

Transformations are reified as objects

Each ―transformation instance‖ (trace) ensures continuous updating of the target model in the presence of ongoing modifications of the source model

General format:

transformation <name> (in im:MM1, out om:MM2) main () {-- <imperative transformation description> }

A transformation occurs by creating an instance of the appropriate transformation and invoking its ―transform()‖ operation

The results can be checked for success or failure

Exceptions can be handled explicitly, etc.

Page 262: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 277

Operational Mapping: Mapping SpecificationOperational Mapping: Mapping Specification

Each mapping is defined as an operation on the appropriate metamodel element

E.g. (see slide xxx):

mapping AssociationClass::UMLAssocClass2MOF(){ // this will create an end object if it does not exist object ca : MOFClass {name := self.end[0].umlclass.name;}; object cb : MOFClass {name := self.end[1].umlclass.name;}; object a1e1 : MOFProperty {name := self.end[0].name; lower := self.end[0].lower; upper := self.end[0].upper;} object a1e2 : MOFProperty {name := self.end[1].name; lower := self.end[1].lower; upper := self.end[1].upper;} ... object ac : MOFAssociation {name := ca.name + „_‟ + cb.name; } }

Page 263: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 278

Operational Mapping: Invoking the MappingsOperational Mapping: Invoking the Mappings

transformation UML2MOF (in um:UML, out mm:MOF)

main (){

im.objectsOfType(AssociationClass)->

map UMLAssocClass2MOF ()}

mapping AssociationClass::UMLAssocClass2MOF() {

...}

Page 264: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 279

Alternative: The Core Language ApproachAlternative: The Core Language Approach

Similar to Relations but simpler

Trace classes need to be specified explicitly

Mappings tend to be more verbose

Guard

Pattern

Domain

Pattern

“check”“check”

Guard

Pattern

Domain

Pattern

“enforce”“enforce”

Guard

Pattern

Trace

Pattern

map <mappingName> {

[check] [enforce] <metamodelName> (<guardPattern>) {<domainPattern>}

[check] [enforce] <metamodelName> (<guardPattern>) {<domainPattern>}

...

where (<guardPattern>) {<tracePattern>} }

Page 265: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 280

Summary: MDA TransformationsSummary: MDA Transformations

A key element of MDA

An operation on MDA models to

Convert models into equivalent models suitable for analysis or viewing

Refine or generalize models (e.g., PIM to PSM, or PSM to PIM)

Generate code from models

OMG provides a technology-neutral standard for defining transformations

Declarative style (Core and Relations)

Imperative style (Operational Mappings)

Work on model transformations is in its infancy and more research is required to deal with scalability, performance, optimization, etc.

Page 266: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 281

Summary (Summary (11))

The definition of a modeling languages comprises a concrete syntax, an abstract syntax, and semantics

Greater emphasis on communication/understanding aspects compared to most programming languages

• E.g., multiple DSMLs, each chosen for its expressiveness

We have neither a deep understanding nor a systematic approach to modeling language design

A discipline lacking theoretical underpinnings but definitely not lacking in controversy

But, a critical discipline to help us contend with the growing complexity of modern software

Page 267: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 282

Summary (2)Summary (2)

Designing a useful domain-specific computer language (modeling or programming) is challenging and requires diverse and highly-specialized skills

Domain expertise

Modeling language design expertise

• No established and reliable theory of modeling language design to guide the designer

Dealing with the fragmentation problem

And remember: if the support infrastructure is inadequate, the language may not be viable

Despite its potential technical excellence

Page 268: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 283

Bibliography/ReferencesBibliography/References A. Kleppe, ―Software Language Engineering‖, Addison-Wesley, 2009

T. Clark et al., ―Applied Metamodeling – A Foundation for Language Driven Development‖, (2nd Edition), Ceteva, http://www.eis.mdx.ac.uk/staffpages/tonyclark/Papers/

S. Kelly and J.-P. Tolvanen, "Domain-Specific Modeling: Enabling Full Code Generation," John Wiley & Sons, 2008

J. Greenfield et al., ―Software Factories‖, John Wiley & Sons, 2004

D. Harel and B. Rumpe, ―Meaningful Modeling: What‘s the Semantics of ‗Semantics‘‖, IEEE Computer, Oct. 2004.

E. Seidewitz, ―What Models Mean‖, IEEE Software, Sept./Oct. 2003.

T. Kühne, ―Matters of (Meta-)Modeling, Journal of Software and Systems Modeling, vol.5, no.4, December 2006.

Kermeta Workbench (http://www.kermeta.org/ )

OMG‘s Executable UML Foundation Spec (http://www.omg.org/spec/FUML/1.0/Beta1 )

UML 2 Semantics project (http://www.cs.queensu.ca/~stl/internal/uml2/index.html)

ITU-T SDL language standard (Z.100) (http://www.itu.int/ITU-T/studygroups/com10/languages/Z.100_1199.pdf)

ITU-T UML Profile for SDL (Z.109) (http://www.itu.int/md/T05-SG17-060419-TD-WP3-3171/en)

Page 269: The ―Theory‖ and Practice of...Flow charts, SA/SD, 90‘s OO notations (Booch, OMT, OOSE, UML 1) Most of them were intended exclusively for constructing descriptive models Informal

© Copyright Malina Software 284

–– THANK YOU THANK YOU –– QUESTIONS, QUESTIONS, COMMENTS,COMMENTS,

ARGUMENTS... ARGUMENTS...


Recommended