UML 关联 - 'role' 的等效代码是什么?
UML association - what is the code equivalent of a 'role'?
UML 关联角色的等效代码是什么?例如,我有下面的 UML 图:
有一个从 Graph class 到 GraphNode class 的关联箭头。关联箭头旁边是文本 -nodesMap 0..*
。我理解这是与角色名nodesMap的关联关系。关系是从0到多。我有两个关于此图及其等效代码的问题:
- 角色前面的破折号是什么意思? nodesMap 是私有的吗?
- Graph class 中的 nodesMap 是什么?它是 Graph class 的成员吗?此外,如果它是一个成员,它的类型是什么,为什么它没有与其他变量一起列出,就像在 GraphNode class(例如,组件属性)中一样?
What does the dash before the role mean? Is nodesMap private?
是的,符号是:
+
: public
-
:私有
#
: 受保护
~
: 包裹
What is nodesMap in the Graph class? Is it a member of the Graph class?
是的,对于一种语言,Java nodesMap 是一个属性。在 UML 中,这意味着 属性 端由 Graph 拥有。
Further, if it is a member, what is its type and why isn't it listed with the other variables, like in the GraphNode class (for example, the component attribute)?
它的类型是GraphNode的集合,因为关系的目标是classGraphNode和重数是 0..* 表示任何大于等于 0 的数字。支持集合的方式是免费的,没有额外的信息说明它是否有序 and/or 元素是唯一的等
请注意,您还可以使用 - nodesMap: GraphNode [0..*]
在 class 中的其他属性中表示该属性
UML 关联角色的等效代码是什么?例如,我有下面的 UML 图:
有一个从 Graph class 到 GraphNode class 的关联箭头。关联箭头旁边是文本 -nodesMap 0..*
。我理解这是与角色名nodesMap的关联关系。关系是从0到多。我有两个关于此图及其等效代码的问题:
- 角色前面的破折号是什么意思? nodesMap 是私有的吗?
- Graph class 中的 nodesMap 是什么?它是 Graph class 的成员吗?此外,如果它是一个成员,它的类型是什么,为什么它没有与其他变量一起列出,就像在 GraphNode class(例如,组件属性)中一样?
What does the dash before the role mean? Is nodesMap private?
是的,符号是:
+
: public-
:私有#
: 受保护~
: 包裹
What is nodesMap in the Graph class? Is it a member of the Graph class?
是的,对于一种语言,Java nodesMap 是一个属性。在 UML 中,这意味着 属性 端由 Graph 拥有。
Further, if it is a member, what is its type and why isn't it listed with the other variables, like in the GraphNode class (for example, the component attribute)?
它的类型是GraphNode的集合,因为关系的目标是classGraphNode和重数是 0..* 表示任何大于等于 0 的数字。支持集合的方式是免费的,没有额外的信息说明它是否有序 and/or 元素是唯一的等
请注意,您还可以使用 - nodesMap: GraphNode [0..*]