Search code examples
umlclass-diagram

Pointers, Lists and Vectors attribute names necessary in the UML diagram?


I have a short question:
Should I name attributes of types like a List, Arrays, Vectors or Pointers to objects (not primitive type) in the UML diagram or the only association/aggregation/composition arrows are enough?

Example: which of these diagrams is correct?

enter image description here

or

enter image description here


Solution

  • In UML, your second diagram would be correct if you wrote the property names at the far ends of the associations. While UML properties are allowed to be unnamed, it is not a good practice. Use association ends to indicate why the relationship exists. Sometimes more than one association must exist between one pair of classes, but for different reasons. How would you tell them apart?

    The first diagram shows two properties of each type. One is named and another (at the end of each association) is unnamed. That is incorrect.