Derek K
Derek K

Reputation: 3157

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

Upvotes: 2

Views: 5455

Answers (2)

Jim L.
Jim L.

Reputation: 6529

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.

Upvotes: 2

Adi Levin
Adi Levin

Reputation: 5233

This really depends on what you're trying to convey in this architectural drawing. The purpose of the drawing is to help reason about the structure of the software. It should not be used to represent all of the details of implementation. If you put too much detail in it, it becomes cluttered, and it is hard to keep it consistent with the source code as changes occur.

The UML drawing should be more abstract than the implementation. It should hide details on purpose, so that it conveys the external view of classes, and not how they are implemented internally. You generally don't want users of classes to assume too much about their internal implementation, therefore you don't want to expose it too much.

Also, an architecture is typically represented by several drawings - not one. Try to have each drawing focus on one level of abstraction. If you have a few high level classes that represent the main logic of the application, and many low level classes, it makes sense to have a drawing of just the high level classes separately.

Upvotes: 0

Related Questions