What's the UML syntax for multiplicity? ( inside the class box )

≯℡__Kan透↙ 提交于 2019-12-12 17:33:25

问题


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        |
 |               | ------------------|               |
 |----------------                   -----------------


来源:https://stackoverflow.com/questions/2037757/whats-the-uml-syntax-for-multiplicity-inside-the-class-box

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!