Class diagrams -Multiplicity

Associations and aggregations may also have multiplicity. This allows us to specify how many objects of a certain type will be used or created by another class. The diagram below shows that a object of class Foo has access to N copies (or unlimited number) of Bar objects but a Bar object will only have access to a single Foo object.

Multiplicity can be specified as a single number or as range. Below are some examples-

3 – Must have 3 copies of the object

0...1 – can have none or one

2...5 – Can have between 2 or 5 objects

1...N – Must have 1 to any number of objects

You may also sometimes see * or another better instead of N. It means the same thing!

 

Final note – Sometimes a ellipsis is used to cut down the amount of superfluous attributes or methods which may not semantically enrich a diagram. It essentially represents hidden attributes or methods. The diagram below shows an example -