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:
Some questions arise in my mind here:
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;
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
?
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.
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/
A comment actually represents two things:
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
)