gpt4 book ai didi

associations - UML类图: difference between Navigation and Ownership

转载 作者:行者123 更新时间:2023-12-02 07:00:10 26 4
gpt4 key购买 nike

我阅读了以下帖子

但是我仍然不清楚 UML 类图关联的“导航”和“所有权”之间的区别。此外,UML 2.5同时发布。

该规范规定如下:

Association ends owned by classes are always navigable, while thoseowned by associations may be navigable or not.

  1. 这意味着下面的示例 c 无效。示例 a 和 b 都是有效的,在这两种情况下,右端都是可导航的。但是,在示例 b 中,左端不可导航。

    我说得对吗?

  2. 导航和所有权之间的语义差异是什么?导航是访问相反类的“通用”方式,而所有权强制类具有属性吗?

enter image description here

最佳答案

规范说明

Dot notation is used to denote association end ownership, where the dot shows that the Class at the other end of the line owns the Property whose type is the Class touched by the dot.

所以ab是有效的,c是奇怪的。假设左侧开始类A,右侧开始类B。如果 a A 拥有一个 B 类型的属性,因此它可以导航到该属性。 Case b 显式添加了 A 可以导航到 B 的信息,通过使用点已经很明显了。如果 c B 拥有 A 类型的属性(因此可以导航)。此外,您指示从 AB 的导航,但不显示所有权。所以这很奇怪。

所有权只是表示有一些东西(指针)可以导航到另一个对象。引用规范(第 126 页):

Navigation arrows may be shown, but if shown, they shall agree with the navigation of the Association’s ends.

及后续版本(第 201 页):

In practice, it is often convenient to suppress some of the arrows and crosses that signify navigability of association ends. A conforming tool may provide various options for showing navigation arrows and crosses. As with dot notation, these options apply at the level of complete diagrams.

  • Show all arrows and crosses. Navigation and its absence are made completely explicit.
  • Suppress all arrows and crosses. No inference can be drawn about navigation.
  • Suppress all crosses. Suppress arrows for Associations with navigability in both directions, and show arrows only for Associations with one-way navigability. In this case, the two-way navigability cannot be distinguished from situations where there is no navigation at all; however, the latter case occurs rarely in practice.

导航没有实际用途(在大多数情况下)。您可以通过添加角色名称来显示导航,以明确 AB 视为 role。末尾附近有一个带有十字的符号,明确禁止导航。这在某些情况下可能很有用。

可能会注意到,与“所有权”(使用较多)相比,规范对“导航”(仅 grep 出现的情况)相当沉默。这可能是因为最近引入了所有权。

关于associations - UML类图: difference between Navigation and Ownership,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45595787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com