Slides of the talk at ECMDA 2011, Brimingham, June 2011
ABSTRACT:
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.
El doctorado en Informática: ¿Nuevo vino en viejas botellas? (Charla U. Sevil...
Improving Naming and Grouping in UML
1. Improving Naming and Grouping in UML Antonio Vallecillo Universidad de Málaga, Spain http://www.lcc.uma.es/~av
2. Context Specification of non-trivial systems using UML and ODP UML as base language UML4ODP Profiles to represent ODP concepts Viewpoint Modeling to structure the systems specs Five viewpoints Correspondences between them Retail, eHealth, Aerospace Heterogeneous Federated modeling ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 2
3. UML package The package is the UML mechanism for groupingmodeling 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 namesto refer to elements in other packages PackageMerge Allows extending the contents of one package with the contents from another The receiving package is modified, being replaced by the duplicate-free union of the two packages Names are used to identify corresponding elements [Import deals with naming issues, Merge deals with contents] ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 3
4. Issues ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 4
5. 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 name This assumes a single global naming scheme It hinders heterogeneous federated modeling ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 5
6. Issues about PackageImport It does not work well with name clashes Name resolution is complex or even impossible sometimes Has side-effects The situation gets worse under the presence of OCL ECMFA 2011 A. 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]
7. Issues about PackageImport It does not work well with name clashes Name resolution is complex or even impossible sometimes Has side-effects The situation gets worse under the presence of OCL ECMFA 2011 A. 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]
8. Issues about PackageImport It does not work well with name clashes Name resolution is complex or even impossible sometimes Has side-effects The situation gets worse under the presence of OCL ECMFA 2011 A. 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]
9. 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 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 9
10. Our proposal ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 10
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] ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 11
12. 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 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 12
13. 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 entities A name is a term that refers to an entity, in a naming context A naming action associates a name to an entity Naming contexts are named elements ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 13 [ISO 14771: ODP Naming Framework, 1999]
14. Some examples ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 14 “perro” = “Inglés::dog”
15. 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) : NamedElementbody: 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 contextNamedElement::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 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 15
16. Putting it all together ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 16
17. The new elements ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 17
18. Back to the future… Integrating all this in UML ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 18
19. Packages and groups can be used together in specifications contextPackageableElement::name : Identifier derive: self.name(self.group.namingContext)) context Package inv NamesItsElements: self.member->forAll(name = name(self.namingContext)) Groups and Packages ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 19
20. 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 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 20
21. New import operations contextNamingContext::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) elseresult = ( n.resolve(self) = e ) endif contextGroup::import(n : Identifier, e : NamedElement): Boolean body: self.namingContext.import(n,e) contextGroup::include( n : Identifier ) pre: n.canResolve(self.namingContext) post: self.member->includes(n.resolve(self.namingContext)) ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 21
22. Merging ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 22
23. A new semantics for Merge It now creates a new group with the result of the merge Side-effect free User-defined merging operation between elements ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 23
24. Conclusions New UML grouping and naming mechanisms Elements can belong to more than one group Elements can have different names in different contexts Pros Backwards compatible with UML (almost) Package is a kind of Group Element names are now derived attributes Import and Merge operations ironed out Side-effects free Clear conflict detection Aligned with existing and mature international standards Cons UML may ignore it… Future work Synonyms, refinement of operation specifications, fine-tuning of constraints (e.g., name+types), tool support for operations UML “redefines” ECMFA 2011 A. Vallecillo: "Improving Naming and Grouping in UML" 24