5

What is the importance of association multiplicity in class diagrams? Why and when should we indicate them? Thanks.

Ristovak
  • 491
  • 1
  • 5
  • 10
  • @burnt_hand: I don't think so. It's very easy to forget these things in a rush because the designer thinks those multiplicities are known to everybody anyway. – Thorsten79 May 19 '10 at 07:47

3 Answers3

3

They allow the designer a quick visual way of communication that would be difficult without multiplicities. You would have to use notes or other space-eating annotations in the diagram.

In a UML diagram I want to have multiplicities for all other associations other than one-on-one.

Why?

  • One-on-one is the visual cue you get from a simple association. It's sort of the default.
  • Multiplicities contain domain knowledge (car->wheel is usually a 1 -> 4 association. The association without the multiplicity looks like a car has one wheel.
  • A designer can "deserialize" the things he thinks are granted because everybody in the domain probably knows them, but the developer probably does not know!
Thorsten79
  • 10,038
  • 6
  • 38
  • 54
1

They convey the business rules more directly. E.g an house contains one or more rooms.

fastcodejava
  • 39,895
  • 28
  • 133
  • 186
1

UML gets used in many ways. There are a huge number of things a class diagram could show. If you're trying to exhaustively document a system's design then you may need to show them all. If you're trying to explain a more specific aspect of the design, only show it if it's relevant (i.e. has a bearing on how that aspect would be designed/implemented).

pdbartlett
  • 1,521
  • 10
  • 18