Download presentation
Presentation is loading. Please wait.
Published byEmery Park Modified over 9 years ago
1
OVERVIEW OF MDE AND IN CLASS EXAMPLES try your luck at modeling UML4-1 UML 1.class diagrams 2.object diagrams and constraints 3.metamodeling 4.examples
2
Finite State Machines Yet another UML diagram Nodes represent states in a computation; edges represent legal state transitions UML4-2 this is a high-level description of an ugly Java program I would rather draw this than write this ugly program
3
Model Driven Engineering Basic idea is this: programmer draws a model graph of the software that he wants to build tool translates the graphical model into a database of tuples tool evaluates metamodel constraints if no errors, tool generates code or whatever from these tables UML4-3 (1) draws FSM using xlate graph to tables FSM Tool (2) press button to generate velocity code generation FSM code validate constraints FSM Application Engineer
4
Model Driven Engineering What I’ve been showing you is how MDE tools work input graphs – like your homework – are fancy object diagrams you are manually translating object diagrams to databases: tools do this automatically you are writing the constraints that tools invoke assignment P2 you will be writing the scripts to generate code or whatever as output P3 UML4-4 (1) draws FSM using xlate graph to tables FSM Tool (2) press button to generate velocity code generation FSM code validate constraints FSM Application Engineer
5
Where does MetaModeling Fit in? The tool that allows you to draw diagrams – it must use a metamodel to understand whether an engineer’s diagram makes sense it conforms to the tool’s metamodel UML4-5 (1) draws FSM using xlate graph to tables FSM Tool (2) press button to generate velocity code generation FSM code validate constraints FSM Application Engineer mm
6
Everything is a Graph to MDE nothing special about FSMs, hence the generality of MDE Message Sequence Charts Data Flow Model Flow Chart Petri Net Network Architecture Logic Circuit Diagram MDE1-6
7
An MDE Tool for These Domains Uses a metamodel for message sequence charts, logic circuit diagrams, data flow models, etc. to allow engineers to draw diagrams and make sure that the diagrams conform to make sure there are no stupidities that can’t be mapped to code UML4-7 Message Sequence Charts Data Flow Model Flow Chart Petri Net Network Architecture Logic Circuit Diagram
8
What you are Learning Are the basics behind Model Driven Engineering There are MDE tools take a meta-model and automatically generate tools that allow programmers to draw object models that are customized for a domain like FSMs they translate input object diagrams to databases they evaluate the Prolog constraints that you have defined they generate whatever from this database You will see all the pieces brought together in program P3 UML4-8
9
METAMODELING lets get back to UML4-9
10
H1: Category Diagrams UML4-10 (a) (b)
11
To Us… They are just directed graphs and yes, I inadvertently made things more complicated talking about compound arrows I ignored that part of the problem when grading Always remember: models capture very little of domain semantics does the Java compiler understand your program? NO – it just cares if your program conforms to its metamodel (syntax + type constraints) UML4-11
12
Metamodel UML4-12
13
Tables UML4-13 #name # fromto Domain Arrow #name boolBool intInt unitUnit realReal #namefromto iszero boolint not bool true unitbool false unitbool zero unitint succint int toreal intreal succreal real unit (b)
14
Tables UML4-14 #name # fromto Domain Arrow #name xX yY zZ # fromto ffxy ggyz g f xz (a)
15
Ex #1: Hypergraphs UML4-15 http://en.wikipedia.org/wiki/Hypergraph please note that I include color in this design; color is not fundamental to hypergraphs
16
Class Diagram without Constraints UML4-16 table#attributes node belongsTo hyperEdge please note that I include color in this design; color is not fundamental to hypergraphs table#attributes noden#name belongsTo hyperEdge table#attributes noden#name belongsTob#n#e# hyperEdge table#attributes noden#name belongsTob#n#e# hyperEdgee#namecolor
17
Tables UML4-17 n#name v1 v2 v3 v4 v5 v6 v7 Node 1 e#namecolor e1 yellow e2 salmon e3 green e4 purple HyperEdge 2 b#n#e# b1v1e1 b2v2e1 b3v2e2 b4v3e1 b5v3e2 b6v3e3 b7v4e4 b8v5e3 b9v6e3 BelongsTo
18
Constraints Enforce cardinality constraints – every edge must contain at least one vertex Lots of other possibilities: check belongsTo column for nulls – error exists if nulls exist check unique name for each vertex check unique name & color for each edge UML4-18 atLeastOne(H) :- belongsTo(_,_,H). NoEmptyEdges :- forall(hyperEdge(H,_,_),atLeastOne(H)).
19
Amaze Your Friends! When you see: You exclaim “It’s a hypergraph with one edge!” UML4-19
20
Amaze Your Friends! When you see: You exclaim “It’s a hypergraph with two edges!” UML4-20
21
Ex #2: Labeled Mixed Graphs UML4-21 V = { 1, 2, 3, 4, 5 } A = {A1, A2, A3, A4} E = {E1, E2} 1 34 25 A1 A2 A3 A4 E1 E2 http://en.wikipedia.org/wiki/Mixed_graph#Mixed_graph
22
Class Diagram without Constraints UML4-22
23
Tables UML4-23 n#label Node 1 e#label Edge 2 a#labelstartsAtendsAt Arc c#e#n# Connects 3 V = { 1, 2, 3, 4, 5 } A = {A1, A2, A3, A4} E = {E1, E2} 1 34 25 A1 A2 A3 A4 E1 E2 n#label n11 n22 n33 n44 n55 e#label e1E1 e2E2 c#e#n# c1e1n1 c2e1n4 c3e2n3 c4e2n4 a#labelstartsAtendsAt a1A1n5n1 a2A2n1n2 a3A3n2n3 a4A4n5n3
24
Constraints Unique labels for nodes, edges, arcs No nulls for arc or edge endpoints Endpoints for arcs and edges must exist UML4-24
25
Ex #3: Recall Survey this is harder UML4-25 What is a UML (class diagram) model of such surveys?
26
Class Diagram Question: do we need to normalize associations? Question: is this a model or a meta-model or a meta-meta-model? UML4-26 abstract
27
Ans: Meta-Meta-Model! UML4-27 s1s1 s4s4 s3s3 s2s2 metasurvey survey instances i1i1 i3i3 i2i2 i4i4 i6i6 i5i5 surveys
28
Diagram-2-Table Mapping UML4-28 table#attributes questionairen#name questionq#textin simpleQuestionq#textinqs# questionSetq#textin answerChoicea#choicevalueq# always empty table – why?
29
Tables UML4-29 n#name n1CS373S survey questionnaire 1 q#textinqs# q1Status at UTn1null q2Major or Deptn1null q3Registered?n1null q4BNFn1q19 q5Reg. Expr.n1q19 ……n1q19 q18Design Patternsn1q19 SimpleQuestion 2 AnswerChoice #ChoiceValueQuestion A11 st yearq1 A22 nd yearq1 A33 rd yearq1 A44 th yearq1 A55 th yearq1 A6CSq2 A7ECEq2 A8Otherq2 A9Yesq3 A10Noq3 A11Not Familiarq19 A12Somewhatq19 A13Veryq19 k#TextIn q19Knowledge survey n1 QuestionSet 3
30
Constraints Check cardinalities Check for unique names? UML4-30
31
Next Lecture We have looked at UML models transformations that map models to databases model constraints – written in prolog meta-models Next we will look at: model refactorings why they are relevant to modeling Java program refactorings UML4-31
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.