英文:
How to read multiplicity in UML
问题
I'm learning about UML, but I am confused about the concept of multiplicity. Consider the Customer
class and Order
class, in this diagram:
- First: which class does the number 1 belong to? what about the 0..*?
- Second: 1 on the line up, 0..* on the line down, Are there strict restrictions?
- Third: how to read the relation between
Customer
class andOrder
class?
英文:
I'm learning about UML, but I am confused about the concept of multiplicity. Consider the Customer
class and Order
class, in this diagram:
-
First: which class does the number 1 belong to? what about the 0..*?
-
Second: 1 on the line up, 0..* on the line down, Are there strict restrictions?
-
Third: how to read the relation between
Customer
class andOrder
class?
答案1
得分: 2
以下是翻译好的部分:
-
"The number
1
is a shortcut for1..1
, which means at least one and at most one, so in summary, exactly 1."- 数字
1
是1..1
的快捷方式,意味着至少一个且最多一个,总结起来就是恰好 1。
- 数字
-
"In the context of your diagram, it means that that for every instance of
Order
on the other side, there is exactly 1 "associated"Customer
instance (the correct term should be "linked" since a link is to an association what an object is to a class)."- 在你的图表背景下,这意味着对于另一侧的每个
Order
实例,恰好有一个“关联”的Customer
实例(正确的术语应该是“链接”,因为链接是与关联相对应的,就像对象与类相对应一样)。
- 在你的图表背景下,这意味着对于另一侧的每个
-
"A multiplicity of
1..5
would mean at least 1 and at most 5."1..5
的多重性意味着至少 1 个且最多 5 个。
-
"The
0..*
multiplicity, which can also be noted with the shortcut*
, means at least 0 (i.e there can be none) and no upper limit (i.e there can be a huge number of associated instances). So for everyCustomer
instance, there may be none, one, or many more linkedOrder
instances."0..*
的多重性,也可以用快捷方式*
表示,意味着至少 0 个(即可能没有)且没有上限(即可能有大量关联实例)。因此,对于每个Customer
实例,可以没有、一个或多个链接的Order
实例。
-
"This shall answer your first point, as well as your last point. You need to define "strict restrictions", as this is not an UML term."
- 这应该回答了你的第一个问题以及最后一个问题。你需要定义“严格限制”,因为这不是 UML 的术语。
英文:
The number 1
is a shortcut for 1..1
, which means at least one and at most one, so in summary, exactly 1.
In the context of your diagram, it means that that for every instance of Order
on the other side, there is exactly 1 "associated" Customer
instance (the correct term should be "linked" since a link is to an association what an object is to a class).
A multiplicity of 1..5
would mean at least 1 and at most 5.
The 0..*
multiplicity, which can also be noted with the shortcut *
, means at least 0 (i.e there can be none) and no upper limit (i.e there can be a huge number of associated instances). So for every Customer
instance, there may be none, one, or many more linked Order
instances.
This shall answer your first point, as well as your last point. You need to define "strict restrictions", as this is not an UML term.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论