Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a diamond sign signify in UML class diagrams?

Consider the below two diagrams. The top one contains a plain arrow at the right end, and the bottom one contains an arrow with a diamond at the left end and a plain arrow at the right end. The great book GoF has usages of both of these two kinds of diagrams.

I want to understand what does the diamond signify in the second case, and which one of these two gives a stronger association between Customer and Order.

Is the Customer class responsible for the lifecycle of Order class in either of the two cases?

enter image description hereenter image description here

like image 993
Geek Avatar asked Feb 28 '13 17:02

Geek


People also ask

What is a white diamond in UML?

An association in a UML class diagram can be an aggregation or composition in order to define a "part-of" relationship. An aggregation is depicted with a white diamond on one end of the relationship, a composition with a black diamond.

What does a solid diamond mean in an object model?

In the case of composition we refer to the parts as "component" object types and to the "composed" object type as a composite object type. The symbol for aggregation is a transparent diamond shape, whereas a composition uses a solid black diamond shape.

What are the symbols used in the UML class diagram?

Pre-drawn UML class diagram symbols represent class, template class, object, item, package, interface, dependency, composition, and association, etc. These symbols help create accurate diagrams and documentation. UML class diagram templates offer you many useful shapes.

What does Black diamond mean in class diagram?

A dark black diamond indicates a 'composition' relationship whilst a hollow diamond indicates an 'aggregation'.


3 Answers

If there is no diamond, then we have a simple association.

If the diamond is left empty, it signifies it is an aggregation. This relation is stronger than a simple association. In this case a Customer aggregates Orders.

If the diamond is black, this means it is a composition, which is even stronger than an aggregation because the composite class cannot be composite by other classes. Its "life" depends on the container.

I think it's explained a little bit more clearly, at:

  • Ezra, Aviad (May 28, 2009) "UML Class Diagram: Association, Aggregation and Composition"
like image 115
C.Champagne Avatar answered Oct 17 '22 14:10

C.Champagne


The customer and order is a "has-a" composition relationship because if the customer ceases to exist so does his/her order. Therefore, there is a life cycle dependency between the container (customer) and the instances within that container (order). When the container ceases to exist so does all its instances.

On the other hand, if we say a customer has a book. In this case, we have a "has-a" aggregation relationship. Because if the customer ceases to exist, the book is still available.

like image 33
Rubens Gomes Avatar answered Oct 17 '22 14:10

Rubens Gomes


It signifies aggregation. From wikipedia:

In UML, it is graphically represented as a hollow diamond shape on the containing class end of the tree with a single line that connects the contained class to the containing class.The aggregate is semantically an extended object that is treated as a unit in many operations,although physically it is made of several lesser objects.

http://en.wikipedia.org/wiki/Class_diagram

like image 9
Mike Darmetko Avatar answered Oct 17 '22 14:10

Mike Darmetko