Reputation: 13
Similar questions have been asked, but this does not fully address my problem:
I am having problem with the following statement made by my teacher:
Let's assume the following description:
[...]Each operation holds a sequence of tasks to be executed on a required quality level - for each task there is an associated quality level selected from the list of available quality levels for this task.[...] (Operation holds number of other attributes as well).
Now I have drawn the following "class diagram":
Questions:
Can I have self-defined data types as part of my class diagram (as a class) or can these be used only as attributes within other classes?
If these data types can be used only as attributes, then I do not know how I can mark the fact that the collection is ordered and unique other by adding this attribute to a class - which - according to my teacher - is not allowed - because then I would be having a collection of a type which is neither an in-built type or self-defined type as an attribute.
According to my knowledge adding an attribute to a class and specifying this collection is ordered is the only way of marking such property and cannot be achieved with multiplicity.
Can someone please shed a bit of light on what is the proper notation?
Upvotes: 1
Views: 3860
Reputation: 13784
You can have as many self defined Datatype
on your diagram as you want, but beware: there's a difference between Datatype
and a Class
UML allows to use both Classes
and Datatypes
to be the type of your Attribute
.
In UML Attributes
and Associations
are often interchangeable. The defining characteristics of both are defined in Property
, which includes multiplicity and other constraints such as {ordered}
However there are best practices in use that your teacher may be referring too. It is quite sensible to use attributes for relations to Datatypes
and associations for relations to Classes
. For more information about this see UML Best Practice: Attribute or Association
Upvotes: 3