如何阅读UML中的多重性

huangapple go评论55阅读模式
英文:

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 and Order 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:

如何阅读UML中的多重性

  • 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 and Order class?

答案1

得分: 2

以下是翻译好的部分:

  1. "The number 1 is a shortcut for 1..1, which means at least one and at most one, so in summary, exactly 1."

    • 数字 11..1 的快捷方式,意味着至少一个且最多一个,总结起来就是恰好 1。
  2. "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 实例(正确的术语应该是“链接”,因为链接是与关联相对应的,就像对象与类相对应一样)。
  3. "A multiplicity of 1..5 would mean at least 1 and at most 5."

    • 1..5 的多重性意味着至少 1 个且最多 5 个。
  4. "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."

    • 0..* 的多重性,也可以用快捷方式 * 表示,意味着至少 0 个(即可能没有)且没有上限(即可能有大量关联实例)。因此,对于每个 Customer 实例,可以没有、一个或多个链接的 Order 实例。
  5. "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.

huangapple
  • 本文由 发表于 2023年7月13日 11:31:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76675708.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定