improving naming and grouping in uml
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
Improving Naming and Grouping in UML
Antonio VallecilloUniversidad de Málaga, Spain
http://www.lcc.uma.es/~av
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
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
Issues
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 4
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
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]
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]
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]
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
Our proposal
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 10
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
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
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]
Some examples
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 14
“perro” = “Inglés::dog”
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
Putting it all together
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 16
The new elements
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 17
Back to the future…
Integrating all this in UML
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 18
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
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
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
Merging
ECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML" 22
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
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