What's the UML syntax for multiplicity? ( insi

2019-07-21 09:00发布

问题:

I know it is possible to specify the multiplicity within the same class box, without having to draw the link to another class.

My question is, Where should the multiplicity go, after the name or after the type?

Is it:

visibility name multiplicity : type

as

+ clients [0..n] : Client

or

visibility name : type multiplicity

as

+ clients : Client [0..n]

I have two books (Applitying UML and Patterns by Larman and UML and the Unified process by Arlow and Newstadt ) but they differ

回答1:

Pulled from printed page 107 of the UML 2.2 Superstructure OMG Specificiation

Example ...

+createWindow (location: Coordinates, container: Container [0..1]): Window

MORE Examples from the multiplicity element spec, on printed page 97.

Example from Spec on multiplicity.

|--------------------------------------------|
|                Customer                    |
|--------------------------------------------|
| purchase : Purchase [*] {ordered, unique}  |
| account: Account [0..5] {unique}           |
|                                            |
|--------------------------------------------|


回答2:

UML syntax is a diagrammatic syntax. See this multiplicity example from

http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/

Figure 6: An example of a bi-directional association between a Flight class and a Plane class

 -----------------                   -----------------
 | Flight        |0..*         0..1  |  Plane        |
 |               | ------------------|               |
 |----------------                   -----------------


标签: oop uml ooad