250 likes | 363 Views
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
E N D
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 • Can be used by the same CASE tools that understand the meta-metamodel SEG4110 - Topic D - Metamodelling
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 SEG4110 - Topic D - Metamodelling
OMG 4-Layer Architecture SEG4110 - Topic D - Metamodelling
OMG 4-Layer Architecture (Cont.) SEG4110 - Topic D - Metamodelling
MOF Model SEG4110 - Topic D - Metamodelling
MOF Key Abstract Classes SEG4110 - Topic D - Metamodelling
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 SEG4110 - Topic D - Metamodelling
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 SEG4110 - Topic D - Metamodelling
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 SEG4110 - Topic D - Metamodelling
Metaclasses used in class, package, component and deployment diagrams Element importedElement ModelElement * ownedElement name * 0..1 0..1 0..1 Relationship Feature Link Comment Parameter Instance Namespace * GeneralizableElement visibility {ordered} defaultValue * * isRoot kind * isLeaf child Generalization * * * * * * * {ordered} isAbstract * parent specialization discriminator Object owner type * AssociationEnd 2..* 2..* 2..* type Classifier connection participant specification isNavigable * aggregation * 1..* multiplicity Association 0..1 StructuralFeature BehaviouralFeature multiplicity Package * qualifier * Attribute Operation Method * * * * * * initialValue isAbstract body specification Model resident * Class Interface DataType Subsystem Node Component * deploymmentLocation AssociationClass Primitive Enumeration ProgrammingLanguageType 1..* 1..* 1..* EnumerationLiteral UML MetaModel SEG4110 - Topic D - Metamodelling
Element ModelElement name 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 SEG4110 - Topic D - Metamodelling
Feature * visibility {ordered} owner Classifier StructuralFeature BehaviouralFeature multiplicity Attribute Operation Method * * * * * * initialValue isAbstract body specification 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 SEG4110 - Topic D - Metamodelling
Feature * visibility {ordered} Namespace Classifier resident * Class Interface Subsystem Node Component DataType * deploymmentLocation Primitive Structure Enumeration ProgrammingLanguageType 1..* 1..* 1..* EnumerationLiteral Classifier • 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 SEG4110 - Topic D - Metamodelling
Namespace Classifier (cont.) • A classifier defines a namespace and is a generalizable element • Can have • association ends • parameters • instances Feature Parameter Instance * GeneralizableElement visibility {ordered} defaultValue * isRoot kind isLeaf * isAbstract Object owner type * AssociationEnd type Classifier participant specification isNavigable * aggregation * 1..* multiplicity SEG4110 - Topic D - Metamodelling
Relationship Generalization discriminator Association Class AssociationClass 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 SEG4110 - Topic D - Metamodelling
importedElement ModelElement * ownedElement name * 0..1 0..1 0..1 Namespace GeneralizableElement isRoot isLeaf isAbstract Classifier Package * Model Subsystem Namespace • 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 SEG4110 - Topic D - Metamodelling
DataType Enumeration ProgrammingLanguageType Primitive 1..* 1..* 1..* EnumerationLiteral Data Types • 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) SEG4110 - Topic D - Metamodelling
Classifier Namespace Relationship AssociationEnd Class isNavigable aggregation Association multiplicity Customer Account 1..2 * accountNumber balance overdraftLimit Relationship withdraw deposit StructuralFeature multiplicity Generalization discriminator Package Attribute BehaviouralFeature initialValue Chequing Saving CreditCard expiryDate Method Mapping of UML Models to Metamodel Elements (Example) BankSystem SEG4110 - Topic D - Metamodelling
Use Case Diagrams Metamodel SEG4110 - Topic D - Metamodelling
Classifier Classifier UseCase Actor Open file Relationship Relationship Relationship Generalization Open file by Open file by discriminator Extend Include typing name browsing Attempt to open file Browse for file that does not exist Mapping Use Cases Model to Metamodel Ordinary User «extend» «include» System Administrator SEG4110 - Topic D - Metamodelling
State Machines (Main Metamodel) SEG4110 - Topic D - Metamodelling
State SimpleState PseudoState Procedure State Closed Opening 0..1 Enter / pressButton Enter / Transition stop motor run motor forwards 0..1 +entry closingCompleted openingCompleted pressButton Closing Open pressButton Enter / Enter / run motor in reverse stop motor Mapping State Machines to Metamodel StateVertex * 0..1 Event SEG4110 - Topic D - Metamodelling
Extension Mechanisms Metamodel SEG4110 - Topic D - Metamodelling
GeneralizableElement Stereotype Constraint <<geometry> LineSegment {ordered} edge LinearShape 1..* startPoint: Point endPoint: Point length : int Path Line Polygon {startPoint <> endPoint} length {edge->first.startPoint = {edge->size=1} edge->last.endPoint} {length = edge.length->sum} RegularPolygon {edge->forAll(e1,e2 | e1.length = e2.length)} Example SEG4110 - Topic D - Metamodelling