派生类需要钻石链接吗?

发布于 2024-09-10 09:03:21 字数 140 浏览 3 评论 0原文

例如,如果我有以下要求: 1. 狗是一种动物 2. 动物园里有动物 我是否还需要第二个菱形连接器(下方的连接器),如下所示: 图表图像

If, for example, I have the following requirements:
1. Dog is an Animal
2. Zoo has Animal(s)
Do I still need the 2nd diamond connector (the lower one) as shown here:
diagram image

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

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

发布评论

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

评论(4

囍孤女 2024-09-17 09:03:21

第二个菱形连接器是多余的。以下是关于 UML 类图样式的一些建议: http://www.agilemodeling.com/style/类图.htm

The 2nd diamond connector is redundant. Here is some advice about UML class diagrams style: http://www.agilemodeling.com/style/classDiagram.htm

无尽的现实 2024-09-17 09:03:21

第二个菱形连接器表明,除了动物之外,动物园还专门有狗。

The 2nd diamond connector suggests that in addition to animals the Zoo also has specifically Dogs.

初见终念 2024-09-17 09:03:21

您好,在处理 UML 之前,请使用您的常识:)

您想模拟动物园有不同物种的动物吗?那么您不仅应该放入狗,还应该放入猫和所有其他可以存在于该动物园类型(类)中的动物类,并且只使用一个菱形连接器。

Hi before tackling UML use your common sense :)

Do you want to model that zoo have animals of different species ? Then you should not only put dogs but also cats and all other animals class that can exist in THIS zoo type (class) and just use one diamond connector.

や三分注定 2024-09-17 09:03:21
  1. 不要使用白色菱形连接器。使用“组合”或“关联”。在你的情况下,使用“关联”。 “UML distilled”的作者有以下评论

  2. 第二次聚合不是必需的。但是,您可以通过以下方式更改模型:

    (1) 设置第一个聚合的目标角色(在动物端)“动物”。

    (2)删除第二个聚合。

    (3) 创建另一个类 DogZoo,从 Zoo 泛化。

    (4) 绘制从 DogZoo 到 Dog 的聚合,目标角色为“dogs {redefines girls}”

希望有帮助。

  1. Don't use white diamond connector. Use either "composition" or "association". In your case, use "association". The author of "UML distilled" has following comments.

  2. The second aggregation is not necessary. However, you can change your model in this way:

    (1) Set the first aggregation's target role (at Animal side) "animals".

    (2) Delete the second aggregation.

    (3) Create another class DogZoo, generalize from Zoo.

    (4) Draw an aggregation from DogZoo to Dog, with the target role "dogs {redefines animals}"

Hope that helps.

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