Improving Naming and Grouping in UMLAntonio VallecilloUniversidad de Málaga, Spainhttp://www.lcc.uma.es/~av
ContextSpecification of non-trivial systems using UML and ODPUML as base languageUML4ODP Profiles to represent ODP conceptsViewpoint Modeling to structure the systems specsFive viewpoints Correspondences between them Retail, eHealth, AerospaceHeterogeneous Federated modelingECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"2
UML packageThe package is the UML mechanism for groupingmodeling elementsProvides a namespace for its members (P::x)Owns its members (if a package is removed from a model, so are its members)PackageImportAllows using unqualified namesto refer to elements in other packagesPackageMergeAllows 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
IssuesECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"4
Issues about the UML package itselfImposes a hierarchical tree structure, in which one model element cannot belong to more than one packageNo 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 modelingECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"5
Issues about PackageImportIt does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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 PackageImportIt does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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 PackageImportIt does not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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 PackageMergeComplex semanticsComplex side-effectsNo warning of problemsNo tool supportComplex behaviour when used under the presence of PackageImportUML 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 proposalECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"10
A more flexible grouping schemaA 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 schemaA 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 schemaA 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 elementsECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"13[ISO 14771: ODP Naming Framework, 1999]
Some examplesECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"14“perro” = “Inglés::dog”
Name resolutionGiven an identifier and a naming context, name resolution consists of finding a naming action for the identifiercontext Identifier::resolve(C : NamingContext) : NamedElementbody: self.namingAction->any(namingContext = C).entitycontext Identifier::canResolve(C : NamingContext) : Boolean   	body: self.namingAction->exists(namingContext = C)The opposite operation is not that simplecontextNamedElement::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 togetherECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"16
The new elementsECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"17
Back to the future…Integrating all this in UMLECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"18
Packages and groups can be used together in specificationscontextPackageableElement::name : Identifier  derive: self.name(self.group.namingContext))context Package inv NamesItsElements:  self.member->forAll(name = name(self.namingContext))Groups and PackagesECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"19
PackageImportWhy 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 membersPackageImport is needed be able to use an unqualified name to refer to an entity owned by another packageIn our proposal it is enough to add its name to the naming context associated to the groupECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"20
New import operationscontextNamingContext::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 )        endifcontextGroup::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 2011A. Vallecillo:   "Improving Naming and Grouping in UML"21
MergingECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"22
A new semantics for MergeIt now creates a new group with the result of the mergeSide-effect freeUser-defined merging operation between elementsECMFA 2011A. Vallecillo:   "Improving Naming and Grouping in UML"23
ConclusionsNew UML grouping and naming mechanismsElements can belong to more than one groupElements can have different names in different contextsProsBackwards compatible with UML (almost)Package is a kind of GroupElement names are now derived attributesImport and Merge operations ironed outSide-effects freeClear conflict detectionAligned with existing and mature international standardsConsUML 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

Improving Naming and Grouping in UML

  • 1.
    Improving Naming andGrouping in UMLAntonio VallecilloUniversidad de Málaga, Spainhttp://www.lcc.uma.es/~av
  • 2.
    ContextSpecification of non-trivialsystems using UML and ODPUML as base languageUML4ODP Profiles to represent ODP conceptsViewpoint Modeling to structure the systems specsFive viewpoints Correspondences between them Retail, eHealth, AerospaceHeterogeneous Federated modelingECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"2
  • 3.
    UML packageThe packageis the UML mechanism for groupingmodeling elementsProvides a namespace for its members (P::x)Owns its members (if a package is removed from a model, so are its members)PackageImportAllows using unqualified namesto refer to elements in other packagesPackageMergeAllows 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
  • 4.
    IssuesECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"4
  • 5.
    Issues about theUML package itselfImposes a hierarchical tree structure, in which one model element cannot belong to more than one packageNo 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 modelingECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"5
  • 6.
    Issues about PackageImportItdoes not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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]
  • 7.
    Issues about PackageImportItdoes not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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]
  • 8.
    Issues about PackageImportItdoes not work well with name clashesName resolution is complex or even impossible sometimesHas side-effectsThe situation gets worse under the presence of OCLECMFA 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]
  • 9.
    Issues about PackageMergeComplexsemanticsComplex side-effectsNo warning of problemsNo tool supportComplex behaviour when used under the presence of PackageImportUML 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
  • 10.
    Our proposalECMFA 2011A.Vallecillo: "Improving Naming and Grouping in UML"10
  • 11.
    A more flexiblegrouping schemaA 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
  • 12.
    A more flexiblegrouping schemaA 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
  • 13.
    A more flexibleNaming schemaA 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 elementsECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"13[ISO 14771: ODP Naming Framework, 1999]
  • 14.
    Some examplesECMFA 2011A.Vallecillo: "Improving Naming and Grouping in UML"14“perro” = “Inglés::dog”
  • 15.
    Name resolutionGiven anidentifier and a naming context, name resolution consists of finding a naming action for the identifiercontext Identifier::resolve(C : NamingContext) : NamedElementbody: self.namingAction->any(namingContext = C).entitycontext Identifier::canResolve(C : NamingContext) : Boolean body: self.namingAction->exists(namingContext = C)The opposite operation is not that simplecontextNamedElement::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
  • 16.
    Putting it alltogetherECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"16
  • 17.
    The new elementsECMFA2011A. Vallecillo: "Improving Naming and Grouping in UML"17
  • 18.
    Back to thefuture…Integrating all this in UMLECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"18
  • 19.
    Packages and groupscan be used together in specificationscontextPackageableElement::name : Identifier derive: self.name(self.group.namingContext))context Package inv NamesItsElements: self.member->forAll(name = name(self.namingContext))Groups and PackagesECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"19
  • 20.
    PackageImportWhy is thereany 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 membersPackageImport is needed be able to use an unqualified name to refer to an entity owned by another packageIn our proposal it is enough to add its name to the naming context associated to the groupECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"20
  • 21.
    New import operationscontextNamingContext::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 ) endifcontextGroup::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 2011A. Vallecillo: "Improving Naming and Grouping in UML"21
  • 22.
    MergingECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"22
  • 23.
    A new semanticsfor MergeIt now creates a new group with the result of the mergeSide-effect freeUser-defined merging operation between elementsECMFA 2011A. Vallecillo: "Improving Naming and Grouping in UML"23
  • 24.
    ConclusionsNew UML groupingand naming mechanismsElements can belong to more than one groupElements can have different names in different contextsProsBackwards compatible with UML (almost)Package is a kind of GroupElement names are now derived attributesImport and Merge operations ironed outSide-effects freeClear conflict detectionAligned with existing and mature international standardsConsUML 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