Zinovy Diskin and Juergen Dingel Queen’s University Kingston, Ontario, Canada Mappings, maps and...

17
Zinovy Diskin and Juergen Dingel Queen’s University Kingston, Ontario, Canada Mappings, maps and tables: Towards formal semantics for associations in UML 2 The speaker The UML 2.0 Semantics Project

Transcript of Zinovy Diskin and Juergen Dingel Queen’s University Kingston, Ontario, Canada Mappings, maps and...

Zinovy Diskin and Juergen Dingel

Queen’s UniversityKingston, Ontario, Canada

Mappings, maps and tables: Towards formal semantics for associations in UML 2

The speaker

The UML 2.0 Semantics Project

UML SemanticsPresentation

Page 2 Why Associations:

Any UML model of practical interest is built upon the structural base specified by class diagrams. The latter are graphs of classes (nodes) and associations (edges).

“Associations are glue that integrate classes into a system” (Jim Rambaugh).

Metamodeling is based on class diagrams, thence, on asociations.

Hence, semantics of the association construct should be clear and precise. Does UML2 specification meet these requirements?

UML SemanticsPresentation

Page 3 UML2 Spec defines associations in sect.7.3.3.

The 1st sentence of sect. 7.3.3: An association describes a set of tuples whose values refer to typed instances. An instance of an association is called a link.

Description section. An association specifies a semantic relationship that can occur between typed instances. It has at least two ends represented by properties, each of which is connected to the type of the end. More than one end of the association may have the same type. An end property of an association that is owned by an end class or that is a navigable owned end of the association indicates that the association is navigable from the opposite ends, otherwise the association is not navigable from the opposite ends.

Semantics section. For an association with N ends, choose any N-1 ends and associate specific instances with those ends. Then the collection of links of the association that refer to these specific instances will identify a collection of instances at the other end. The multiplicity of the association end constrains the size of this collection.

UML SemanticsPresentation

Page 4 UML metamodel of Associations

UML SemanticsPresentation

Page 5 UML2 metamodel of Association, processed

{subsets memberEnd}

{subsets ownedEnd}

There are some things so serious you have to laugh at them.-- Niels Bohr

UML SemanticsPresentation

Page 6 A model of the Association Problem…

12

3

UML SemanticsPresentation

Page 7…and a model of solution: Consider an appropriate model and different views to it

Net surface(Cylinder 1)

Three views of the model

Side surface(Cylinder 2)

3D-space(Cylinder 3)

UML SemanticsPresentation

Page 8 Our plan

The goal is to build a formal framework where the complex notion of association

can be disassembled into elementary blocks; compose from these blocks a few constructs that can formally

model different aspects of associations as described and used in the Spec;

check the UML metamodel of association against our formal framework (Does it fit in? And if not, then fix it by either pressing it through, or expanding it over, or both :)

UML SemanticsPresentation

Page 9 Three views of association

UML PL & UML DB & UML

Extension is explicit!

UML SemanticsPresentation

Page 10 Lewis Carroll about UML Associations:

'When I use a word,' Humpty Dumpty said, in a rather scornful tone,' it means just what I choose it to mean, neither more nor less.' 'The question is,' said Alice, 'whether you can make words mean so many different things.' 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.' <….> 'When I make a word do a lot of work like that,' said Humpty Dumpty, 'I always pay it extra.'

The question is how much extra do UML committees pay to the terms “association” and “association end”?

UML SemanticsPresentation

Page 11 Adding navigation to tables

Student Course Lecturer

row 1 John UML modeling Smith

row 2 Mary History of music White

row 3

Mary

….

UML modeling

….

Brown

…..

*

UML SemanticsPresentation

Page 12 Ownership and navigability

/f2

{ inverse}

f2

1..3f10..2

?

x ?

f2 is navigable

f2 is not navigable

Structural view Operational view Extensional view

UML SemanticsPresentation

Page 13

Meanings of the terms “association” and “association end“in function of the ownership context

Association A owns an end E

“A” is a table and E is a column name

“A” is a set of mappings between classifiers, which have a common extension [[A]]. End E is a mapping, which is not stored yet can be derived from [[A]]

“A” is a mappings between classifiers, and E is a placeholder for the corresponding part of the multiplicity constraints to this mapping

“A” owns not all its ends

“A” owns all its ends

“E” is navigable

“E” is not navigable

UML SemanticsPresentation

Page 14Metamodel of our formal semantics: Playing LEGO with associations

Property’s context!

Qualifier!

UML SemanticsPresentation

Page 15 UML2 metamodel of Association, processed

{subsets memberEnd}

{subsets ownedEnd}

UML SemanticsPresentation

Page 16 Results and discussion

General conclusion: Semantics of the association construct can be uncovered in a few Semantics and Description sections of the Spec, and is presented there in a sufficiently consistent way. However, the part of this semantics formally captured in the UML metamodel is much poorer and that is why the latter is ambiguous (recall our Cylinder model).

Particular technical problems of the UML metamodel of associations:-- meta-association context is missing, which makes the fundamental

metaclass Property underspecified (in fact, undefined);-- meta-association qualifier is improperly defined: its target must be the

metaclass Role rather then Property;-- a few important constraints are missing (see the paper). Deeper conceptual problems:-- fundamental dichotomy associations-as-mappings vs. associations-as-tables

is not specified;-- fundamental dichotomy basic-derived element of association is not specified.

A these red problems really so bad?

UML SemanticsPresentation

Page 17 Results and discussion (with Carroll and Wittgenstein)

UML as a specification language must be clear, precise and unambiguous. Formal semantics can really help here.

UML as a communication language does not ought anything besides being convenient and usable (like other natural languages). As for multiple meanings of its terms, recall Wittgenstein’s Thesis: The meaning of a word is determined by its use.

Would you tell me, please, which way I ought to go from here?' asked Alice.`That depends a good deal on where you want to get to,' said the Cat. `I don't much care where‘ said Alice. `Then it doesn't matter which way you go,' said the Cat.

Is it possible to reconcile these two UMLs (and a few ones in-between) ?

1) Language = Syntax + Semantics,

the latter is changeable and determined by the context. Hence, annotate UML diagrams with their intended meaning (to specify, to suggest, to inspire :)

2) Introduce into UML special constructs for under-specification

UML is a language, and understanding UML is a linguistic activity