Question

Some questions about the UML Comment specification

In section 7.2, page 63 of the PDF file of the UML 2.5.1 specification, the following diagram is presented along with the description of the UML Comment type:

UML Comment

Some questions arise in my mind here:

  1. Why is there a multiplicity of 0..1 on the composition aggregate end owningElement (next to Element)? A Comment must always have an owningElement since it is not a top-level Package;

  2. The association end annotatedElement is *, which means that zero or more Elements can be annotated. It seems to me that this should be 1..* since (a) there must always be an owningElement, and (b) why would an Element own a Comment if it (the owner) was not also an annotatedElement?

  3. I can see why the same Comment might be applied to several different Elements; however, if one Element owns several Comments, how are they distinguishable from each other? A Comment is not a NamedElement, so we cannot query a single Comment by name, and there is no ordering constraint on the set of Comments.

  4. According to its multiplicity, the Comment body attribute can be empty. Does this make any sense?

The latest specification document can be downloaded here: https://www.omg.org/spec/UML/

 3  36  3
1 Jan 1970

Solution

 2

A comment actually represents two things:

  • The description of an element
  • A note that can be linked to many elements

enter image description here

If it's a description, then it has an owningElement. The description is part of the element, and cannot be shared with other elements.

If it's a note, then it doesn't have an owningElement and it can be used to annotate many elements. (in this case it still has an owner as that relation is inherited from Element)

2024-07-04
Geert Bellekens