类图中关联多重性的重要性是什么?

发布于 2024-09-02 05:37:01 字数 44 浏览 2 评论 0原文

类图中关联多重性的重要性是什么? 我们为什么以及何时应该指出它们? 谢谢。

What is the importance of association multiplicity in class diagrams?
Why and when should we indicate them?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小瓶盖 2024-09-09 05:37:01

它们为设计师提供了一种快速的视觉沟通方式,如果没有多样性,这将是困难的。您必须在图表中使用注释或其他占用空间的注释。

在 UML 图中,我希望除一对一之外的所有其他关联都具有多重性。

为什么?

  • 一对一是您从简单关联中获得的视觉提示。这有点像默认的。
  • 多重性包含领域知识(汽车->车轮通常是 1 -> 4 关联。没有多重性的关联看起来就像汽车有一个轮子。
  • 设计师可以“反序列化”他认为被授予的东西,因为域中的每个人都可能知道它们,但开发人员可能不知道!

They allow the designer a quick visual way of communication that would be difficult without multiplicities. You would have to use notes or other space-eating annotations in the diagram.

In a UML diagram I want to have multiplicities for all other associations other than one-on-one.

Why?

  • One-on-one is the visual cue you get from a simple association. It's sort of the default.
  • Multiplicities contain domain knowledge (car->wheel is usually a 1 -> 4 association. The association without the multiplicity looks like a car has one wheel.
  • A designer can "deserialize" the things he thinks are granted because everybody in the domain probably knows them, but the developer probably does not know!
趁年轻赶紧闹 2024-09-09 05:37:01

它们更直接地传达业务规则。例如,一栋房子包含一个或多个房间。

They convey the business rules more directly. E.g an house contains one or more rooms.

↙温凉少女 2024-09-09 05:37:01

UML 有多种用途。类图可以显示大量的内容。如果您试图详尽地记录系统的设计,那么您可能需要将它们全部展示出来。如果您试图解释设计的更具体的方面,则仅在相关时才显示它(即与该方面的设计/实现方式有关)。

UML gets used in many ways. There are a huge number of things a class diagram could show. If you're trying to exhaustively document a system's design then you may need to show them all. If you're trying to explain a more specific aspect of the design, only show it if it's relevant (i.e. has a bearing on how that aspect would be designed/implemented).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文