Presentation is loading. Please wait.

Presentation is loading. Please wait.

MetaModeling the core of MDE and modeling in general UML

Similar presentations


Presentation on theme: "MetaModeling the core of MDE and modeling in general UML"— Presentation transcript:

1 MetaModeling the core of MDE and modeling in general UML
class diagrams object diagrams and constraints metamodeling examples MDE the core of MDE and modeling in general MetaModeling

2 Today’s Lecture Recall this slide from the last lecture:

3 Today’s Lecture Learn the importance of recursion

4 Terminology model meta-model Let 𝑥 be a model and 𝑋 be a metamodel; 𝑥 belongs to the domain of 𝑋 iff 𝑥 is an instance of 𝑋 if objects & refs satisfy the class diagram of 𝑋 and 𝑥 conforms to 𝑋 if 𝑥 satisfies all metamodel constraints of X. “Conforms to” is a much more difficult constraint to satisfy than “instance of”

5 Examples A Java program that is syntactically-correct is an instance of a Java Language Metamodel if it is type-correct and it conforms to the Java Language Metamodel Example: 2 instances and a model – only one instance conforms

6 Perspective Model to Instances
You create a model M: age of every Employee > min age of department And now you create instances m1 and m2 that conform to the model M m1 M both conform. m2 m1 m2

7 Perspective Instances to Model
You have a collection of instances, such as m1 and m2 What is a model M to which m1 and m2 conform? Called metamodeling m1 m2 M M m1 m2

8 MetaModels Here are 2 instances of a “graph”, which contains nodes and edges What is a class diagram of such graphs? n1 n2 g1 n6 n8 n9 g2

9 One Solution Model What is “normalized” database design?
What is a perfectly good Java representation of this meta model? note arrow ends added to meta model class Node { private String Name; private Set<Edge> edge; } class Edge { private node connects[2];

10 Fundamentals of MetaModeling
RULE: ANY graph can be viewed as an object diagram Here are 2 instances of another kind of graph or object diagram called a UML Class Diagram For simplicity, there are no methods and there are any # of attributes, no inheritance relationships What is a UML class diagram to which these instances conform?

11 Hint... Think Visio Drawing Tool
Each “template” icon on left represents a class of objects dragging icon onto canvas creates an instance of that class so there are 2 classes of objects in a UML class diagram that we’re using Determine attributes of each class Determine relationships & constraints among classes Fire up Visio!

12 Step 1. Identify Shapes Given instance:
What are the shapes that you can drag onto a canvas? they are classes in your metamodel I see boxes and lines. that’s really all that I see now. (Of course, they each have attributes, and attributes are something that will become objects that I can “drag” onto my design canvas)

13 Step 2. Identify Attributes
Given instance: What are the shapes that you can drag onto a canvas? they are classes in your metamodel I see boxes and lines. that’s really all that I see now. (Of course, they each have attributes, and attributes are something that will become objects that I can “drag” onto my design canvas)

14 Step 3. Identify Associations
Look at model instance: Here is its metamodel MM 1 3 2

15 Step 4. Beautify (Rename)
Rename elements, add names to roles, etc. This is almost a metamodel of class diagrams! what is missing?

16 Step 5. Add Constraints Association cardinalities usually turn into constraints attribute-class: verify an Attribute tuple points to an existing Class tuple assocEnd-class: verify an AssocEnd tuple points to an existing Class tuple assocEnd-association: verify every AE points to an existing A tuple association-assocEnd: every A must have 2 AEs attribute-class assocEnd-class assocEnd-association association-assocEnd // every A must have 2 AEs ErrorReport er = new ErrorReport(); er.printReport(System.out); no two attributes of a class have the same name Also no two anchor ends associated to the same class have the same name. And no anchor end of a class has the same name as an attribute of the class. association.stream() .filter(t-> assocEnd.stream(). .filter(x->x.is(“aid”,t.get(“aid”))).count()!=2) .forEach(t->er.add(t.get(“aid”) + “ does not have 2 association ends”);

17 Note! Common for a metamodel to be an instance of itself!
model MM conforms to MM Not an oddity! Requirement for advanced models make sure that you understand what this slide says! conforms to or is an instance of M M m1 m2

18 Diagram-2-Table Mapping Notes
# Table Attribute/Field Class c# name Attribute at# visibility? attrOf AssocEnd ae# visible? cardinality anchoredAt endOf Association k# Table # Attribute Class c# name at# visibility? attrOf AssocEnd ae# visible? cardinality anchoredAt endOf Association Table # Attribute Class c# name AssocEnd Association Table # Attribute Class AssocEnd Association Table # Attribute Class c# name at# visibility? attrOf AssocEnd Association

19 Tabular Representation
Attribute 2 Class 1 a# name visibility attrOf # Name Visibility AttrOf a1 name - cl a2 at a3 visibility? a4 ae a5 visible? a6 cardinality # Name cl Class at Attributes ae AssociationEnd as Association c# name AssocEnd Association ae# name vis? card anchAt endof # name vis? card anchAt endof ae1 attrOf - 1 cl k1 ae2 hasAttr * at ae3 anchoredAt k2 ae4 anchors ae ae5 as k3 ae6 hasEnd 2 4 Create each table + attributes Then fill in (as much as possible) Class and Attribute tables Then AssocEnd and Association Table. Filling in the attributes then becomes more like a puzzle. # k1 k2 k3 k# 3

20 Your Turn: Entity-Relationship Model precursor to UML Class Diagrams
Entity sets classes are boxes & have unique names Attributes are bubbles; underlined attributes are keys Relationships are diamonds with unique names connecting 2 or more boxes Attributes are associated with only one Entity or one Relationship Entity set must have 1+ key attribute; Relationships >0 or more attributes

21 A Solution 1st stab at a solution: Constraints? Problem:

22 A Solution Not Association Normalized 1st stab at a solution:
Constraints? Problem: Constraints (beyond cardinality constraints) C1. Each Bubble belongs to a Box OR Diamond, but never both C2. Each Box has at least 1 keyed attribute C3. Each Diamond has 0+ attributes, 0+ keyed attributes C4. Each Box has a unique name C5. Each Diamond has a unique name C6-7. Bubble names for each box (each diamond) are unique Not Association Normalized

23 A Solution continued... Normalizing Box-Diamond association yields:
Tables? Constraints (beyond cardinality constraints) C1. Each Bubble belongs to a Box OR Diamond, but never both C2. Each Box has at least 1 keyed attribute C3. Each Diamond has 0+ attributes, 0+ keyed attributes C4. Each Box has a unique name C5. Each Diamond has a unique name C6-7. Bubble names for each box (each diamond) are unique

24 A Database Diamond Box Bubble BoxDiamond b# name # name e Employee d
1 2 b# name # name e Employee d Department u University d# name d# name wi worksin dis disciplines Bubble 4 BoxDiamond a# name key? belongsTo a# name key? belongsTo a1 empNo yes e a2 age no a3 deptName d a4 building a5 phone a6 address u a7 3 bd# e# r# bd1 e wi bd2 d bd3 dis bd4 u bd# e# r#


Download ppt "MetaModeling the core of MDE and modeling in general UML"

Similar presentations


Ads by Google