improving naming and grouping in uml

24
Improving Naming and Grouping in UML Antonio Vallecillo Universidad de Málaga, Spain http://www.lcc.uma.es/~av

Upload: antonio-vallecillo

Post on 06-May-2015

513 views

Category:

Documents


0 download

DESCRIPTION

Slides of the talk at ECMDA 2011, Brimingham, June 2011ABSTRACT:The package is one of the basic UML concepts. It is used both to group model elements and to provide a namescope for its members. However, combining these two tasks into a single UML concept can become not only too restrictive but also a source of subtle problems. This paper presents some improvements to the current UML naming and grouping schemata, using the ideas proposed in the reference model of Open Distributed Processing (ODP). The extensions try to maintain backwards compatibility with the existing UML concepts, while allowing more flexible grouping and naming mechanisms.

TRANSCRIPT

Page 1: Improving Naming and Grouping in UML

Improving Naming and Grouping in UML

Antonio VallecilloUniversidad de Málaga, Spain

http://www.lcc.uma.es/~av

Page 2: Improving Naming and Grouping in UML

Context

Specification of non-trivial systems using UML and ODPUML as base languageUML4ODP Profiles to represent ODP concepts

Viewpoint Modeling to structure the systems specsFive viewpoints Correspondences between them

Retail, eHealth, Aerospace

Heterogeneous Federated modeling

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 2

Page 3: Improving Naming and Grouping in UML

UML package

The package is the UML mechanism for grouping modeling elements

Provides a namespace for its members (P::x)Owns its members (if a package is removed from a model, so are its members)

PackageImport Allows using unqualified names to refer to elements in other packages

PackageMergeAllows extending the contents of one package with the contents from anotherThe receiving package is modified, being replaced by the duplicate-free union of the two packagesNames are used to identify corresponding elements

[Import deals with naming issues, Merge deals with contents]

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 3

Page 4: Improving Naming and Grouping in UML

Issues

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 4

Page 5: Improving Naming and Grouping in UML

Issues about the UML package itself

Imposes a hierarchical tree structure, in which one model element cannot belong to more than one package

No flexible organization schema Sometimes we want to group elements according to several criteria (there is no single organizational criteria that fits all purposes)

Elements may have at most one nameThis assumes a single global naming schemeIt hinders heterogeneous federated modeling

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 5

Page 6: Improving Naming and Grouping in UML

Issues about PackageImport

It does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCL

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 6

[In this diagram, the OCL constraint in package P refers with no problems to class A in the outer package]

Page 7: Improving Naming and Grouping in UML

Issues about PackageImport

It does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCL

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 7

[Now, the OCL constraint refers to class A in package Q, which can cause problems if there is no age attribute in A]

Page 8: Improving Naming and Grouping in UML

Issues about PackageImport

It does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCL

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 8

[Now the OCL constraint refers back to class A in Outer package! Class C cannot be directly referenced any more]

Page 9: Improving Naming and Grouping in UML

Issues about PackageMerge

Complex semantics

Complex side-effects

No warning of problems

No tool support

Complex behaviour when used under the presence of PackageImport

UML specification explicitly mentions it is only intended for expert modelers ("Don't do this at home")

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 9

Page 10: Improving Naming and Grouping in UML

Our proposal

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 10

Page 11: Improving Naming and Grouping in UML

A more flexible grouping schema

A group is “a set of objects with a particular relationship that characterizes either the structural relationship among objects, or an expected common behaviour”

[RM-ODP Part 2, clause 10.1]

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 11

Page 12: Improving Naming and Grouping in UML

A more flexible grouping schema

A group is “a set of objects with a particular relationship that characterizes either the structural relationship among objects, or an expected common behaviour”

[RM-ODP Part 2, clause 10.1]

Have you used Gmail grouping scheme using labels?

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 12

Page 13: Improving Naming and Grouping in UML

A more flexible Naming schema

A namespace is a set of terms usable as names (strings, icons, …)A naming context establishes the relations between names and entitiesA name is a term that refers to an entity, in a naming contextA naming action associates a name to an entityNaming contexts are named elements

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 13

[ISO 14771: ODP Naming Framework, 1999]

Page 14: Improving Naming and Grouping in UML

Some examples

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 14

“perro” = “Inglés::dog”

Page 15: Improving Naming and Grouping in UML

Name resolution

Given an identifier and a naming context, name resolution consists of finding a naming action for the identifier

context Identifier::resolve(C : NamingContext) : NamedElement body: self.namingAction->any(namingContext = C).entity

context Identifier::canResolve(C : NamingContext) : Boolean body: self.namingAction->exists(namingContext = C)

The opposite operation is not that simple

context NamedElement::name(C : NamingContext) : Identifier body: self.namingAction->any(namingContext = C).name

…the problem is that this element may not be in that naming context but in others (indirect naming).

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 15

Page 16: Improving Naming and Grouping in UML

Putting it all together

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 16

Page 17: Improving Naming and Grouping in UML

The new elements

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 17

Page 18: Improving Naming and Grouping in UML

Back to the future…

Integrating all this in UML

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 18

Page 19: Improving Naming and Grouping in UML

Packages and groups can be used together in specifications

context PackageableElement::name : Identifier

derive: self.name(self.group.namingContext))context Package inv NamesItsElements:

self.member->forAll(name = name(self.namingContext))

Groups and Packages

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 19

Page 20: Improving Naming and Grouping in UML

PackageImport

Why is there any need for PackageImport?

The need for PackageImport in UML is due to the dual nature of Packages as groups and as naming contexts, and that packages are the exclusive owners their members

PackageImport is needed be able to use an unqualified name to refer to an entity owned by another package

In our proposal it is enough to add its name to the naming context associated to the group

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 20

Page 21: Improving Naming and Grouping in UML

New import operations

context NamingContext::import (n : Identifier, e : NamedElement) : Boolean post: if (self.namingAction.name->excludes(n) and self.namingAction.entity->excludes(e)) then result = true and

self.namingAction-> includes (na | na.name = n and na.entity = e) else result = ( n.resolve(self) = e ) endif

context Group::import (n : Identifier, e : NamedElement): Boolean body: self.namingContext.import(n,e)

context Group::include ( n : Identifier ) pre: n.canResolve(self.namingContext) post: self.member->includes(n.resolve(self.namingContext))

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 21

Page 22: Improving Naming and Grouping in UML

Merging

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 22

Page 23: Improving Naming and Grouping in UML

A new semantics for Merge

It now creates a new group with the result of the mergeSide-effect freeUser-defined merging operation between elements

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 23

Page 24: Improving Naming and Grouping in UML

Conclusions

New UML grouping and naming mechanismsElements can belong to more than one groupElements can have different names in different contexts

ProsBackwards compatible with UML (almost)

Package is a kind of GroupElement names are now derived attributes

Import and Merge operations ironed outSide-effects freeClear conflict detection

Aligned with existing and mature international standards

ConsUML may ignore it…

Future workSynonyms, refinement of operation specifications, fine-tuning of constraints (e.g., name+types), tool support for operationsUML “redefines”

ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 24