25
SEG4110 – Advanced Software Design and Reengineering TOPIC D Metamodelling

SEG4110 – Advanced Software Design and Reengineering

  • Upload
    iren

  • View
    34

  • Download
    0

Embed Size (px)

DESCRIPTION

SEG4110 – Advanced Software Design and Reengineering. TOPIC D Metamodelling. What is a Meta-metamodel?. A metamodel describes information about models A meta-metamodel describes information about metamodels Metamodels that are defined using the same meta-metamodel Can exchange information - PowerPoint PPT Presentation

Citation preview

Page 1: SEG4110 – Advanced Software Design and Reengineering

SEG4110 – Advanced Software Design and Reengineering

TOPIC DMetamodelling

Page 2: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 2

What is a Meta-metamodel?

• A metamodel describes information about models

• A meta-metamodel describes information about metamodels

• Metamodels that are defined using the same meta-metamodel

- Can exchange information- Can be used by the same CASE tools that understand the

meta-metamodel

Page 3: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 3

What is MOF?

• MOF stands for Meta Object Facility• enables meta-metamodeling of UML level metamodels

• It defines a small set of concepts (such as package, class, method, attribute…) that- allow one to define and manipulate models of metadata

(data about data)- are described using a subset UML notation

Page 4: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 4

OMG 4-Layer Architecture

Page 5: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 5

OMG 4-Layer Architecture (Cont.)

Page 6: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 6

MOF Model

Page 7: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 7

MOF Key Abstract Classes

Page 8: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 8

MOF Key Abstract Classes (Cont.)• ModelElement common base Class of all M3-level Classes. Every

ModelElement has a name

• Namespace base Class for all M3-level Classes that need to act as containers

• GeneralizableElement base Class for all M3-level Classes that support generalization (i.e. inheritance)

• TypedElement base Class for M3-level Classes such as Attribute, Parameter, and Constant whose definition requires a type specification

• Classifier base Class for all M3-level Classes that (notionally) define types. Examples of Classifier include Class and DataType

Page 9: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 9

The MOF Model: Main Concrete Classes

• The key concrete classes (or meta-metaclasses) of MOF are as follows:

- Class- Association- Exception (for defining abnormal behaviours)- Attribute- Constant- Constraint

Page 10: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 10

The MOF Model: Key associations• Contains: relates a ModelElement to the Namespace that

contains it

• Generalizes: relates a GeneralizableElement to its ancestors (superclass and subclass)

• IsOfType: relates a TypedElement to the Classifier that defines its type- An object is an instance of a class

• DependsOn : relates a ModelElement to others that its definition depends on- E.g. a package depends on another package

Page 11: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 11

Component

0..10..10..1

ownedElement

Comment

*

Link

1..*1..*1..*

EnumerationLiteral

ProgrammingLanguageTypeEnumerationPrimitive

******

1..*

*

Object

ParameterdefaultValuekind

InstanceNamespace

specialization*

parent

*child

GeneralizableElementisRootisLeafisAbstract

Package

Model

SubsystemDataTypeInterfacedeploymmentLocation

* resident

*

AssociationClass

Class Node

owner

{ordered}

participant

*specification

*

AssociationEndisNavigableaggregationmultiplicity

connection2..*2..*2..*

Association

Methodbody

OperationisAbstract

0..1

qualifier *

AttributeinitialValue

{ordered}*

specification******

* type

Generalizationdiscriminator

Featurevisibility

BehaviouralFeatureStructuralFeaturemultiplicity

Classifier

ModelElementname

Element

Relationship*

*

type

importedElement

*

*

UML MetaModel

Metaclasses used in class, package, component and deployment diagrams

Page 12: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 12

Model Elements• An element is an atomic

constituent of a model.

• Element is the top metaclass in the metaclass hierarchy

• A model element is a named entity in a Model

• It is the base for all modeling metaclasses in UML

- All other modeling metaclasses are either direct or indirect subclasses of ModelElement

ModelElement

name

Element

Page 13: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 13

owner

{ordered}

Methodbody

OperationisAbstract

AttributeinitialValue specification

******

Featurevisibility

BehaviouralFeatureStructuralFeaturemultiplicity

Classifier

*

Features• Feature is an abstract class that

declares a behavioral or structural property of

- an instance of a Classifier - the Classifier itself

• A behavioral feature refers to a dynamic feature of a model element

- E.g. operation or method

• A structural feature refers to a static feature of a model element

- E.g. attribute

Page 14: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 14

• A classifier is an element that describes behavioral and structural features

- E.g. class, data type, interface, component

• Classifier is an abstract class that- declares a collection of Features, such as Attributes, Methods…- has a name, which is unique in the Namespace enclosing the Classifier

Classifier

Component

Structure

1..*1..*1..*

EnumerationLiteral

ProgrammingLanguageTypeEnumerationPrimitive

SubsystemDataTypeInterfacedeploymmentLocation

* resident

*Class Node

Classifier{ordered}

Feature

visibility* Namespace

Page 15: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 15

Classifier (cont.)

*

1..*

*

Object

Parameter

defaultValuekind

InstanceGeneralizableElement

isRootisLeafisAbstract

owner

{ordered}

participant*

specification*

AssociationEnd

isNavigableaggregationmultiplicity

* type

Feature

visibility

Classifier

*

type

Namespace

• A classifier defines a namespace and is a generalizable element

• Can have - association ends- parameters- instances

Page 16: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 16

AssociationClass

Class

Association

Generalizationdiscriminator

Relationship

Relationships

• A relationship is a connection among model elements

• UML defines several relationships such as:

- Association- Generalization

• UML defines other types of relationships that are not shown in this diagram, such as:

- Dependency- Flow

Page 17: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 17

Namespace

0..10..10..1

ownedElement

NamespaceGeneralizableElementisRootisLeafisAbstract

Package

ModelSubsystem

Classifier

ModelElementname

*

importedElement

*

*

• A namespace is a part of a model that contains a set of other model elements

- E.g. Associations and Classifiers

- the name of an owned model element is unique within the namespace

• Namespace is an abstract metaclass and it subclasses are

- Classifier- Package

Page 18: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 18

Data Types

1..*1..*1..*

EnumerationLiteral

ProgrammingLanguageTypeEnumerationPrimitive

DataType

• UML Data types include - primitive built-in types (such as integer and string) - definable enumeration types (such as Boolean whose literals are false and

true)

• Programming languages data types - are specified according to the semantics of a particular programming language - are not portable among languages (except by agreement among the languages)- do not map into other UML classifiers

• Enumerations are a user-defined data types whose instances are literals (specified by the user)

Page 19: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 19

Mapping of UML Models to Metamodel Elements (Example)

Customer Account

accountNumberbalanceoverdraftLimit

CreditCard

expiryDate

*1..2

withdrawdeposit

SavingChequing

BankSystem

Generalizationdiscriminator

Relationship

Association

RelationshipAssociationEnd

isNavigableaggregationmultiplicity

Class

ClassifierNamespace

Package

AttributeinitialValue

StructuralFeaturemultiplicity

Method

BehaviouralFeature

Page 20: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 20

Use Case Diagrams Metamodel

Page 21: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 21

Mapping Use Cases Model to Metamodel

Generalizationdiscriminator

Relationship

Include

Relationship

Actor

Classifier

UseCase

Classifier

Extend

Relationship

Open file by typing name

Open file by browsing

Open file

System Administrator

Browse for file

Ordinary User

Attempt to open file that does not exist

«extend» «include»

Page 22: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 22

State Machines(Main Metamodel)

Page 23: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 23

Mapping State Machines to Metamodel

SimpleState

State

PseudoState

StateVertex

Event

Transition

0..1

*

Enter / run motor forwards

Enter / run motor in reverse

Enter / stop motor

Enter / stop motor

openingCompleted

closingCompleted

pressButton

pressButton

pressButton

Closing Open

OpeningClosed

Procedure

State

0..1 +entry

0..1

Page 24: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 24

Extension Mechanisms Metamodel

Page 25: SEG4110 – Advanced Software Design and Reengineering

SEG4110 - Topic D - Metamodelling 25

Example

LinearShape

startPoint: Point1..*edge <<geometry>

LineSegment

Path Line Polygon

RegularPolygon

endPoint: Point

{startPoint <> endPoint}

{ordered}

{edge->size=1}

{edge->forAll(e1,e2 | e1.length = e2.length)}

length : int

length{length = edge.length->sum}

{edge->first.startPoint = edge->last.endPoint}

Stereotype

GeneralizableElement

Constraint