我一直认为 UML 聚合被定义为路径开头的黑色(实心)菱形,结尾处没有箭头:
|--------| |--------|
| :MyA |<>------| :MyB |
|--------| |--------|
今天我遇到了这样的符号<>----->
(右端有一个明确的箭头)。所以我在 UML 2.4 规范中查找,实际上找到了两个版本的参考资料。
我最喜欢的参考:Craig Larman 的《UML 和模式》只提到第一个版本,没有箭头。在 UML 规范中我发现了一个关于通航端,但我不确定这是否相关以及有什么区别?
有人可以更彻底地解释这一点并给出每个版本的使用示例吗?
Any association end can be designated to be "navigable" with the help of a navigability arrow. However, UML's notion of "navigability" does not have a precise meaning and people confused it with the concept of an association end being owned by the class at the other end. This concept of association end ownership by a class means that the association end corresponds to a reference property of that class. This issue has only been clarified in last year's new UML version 2.5, which has introduced a new visual notation for association end ownership, a "dot" as in . This is most likely the intended meaning of what you came across, namely , and what it really means is the following reference property:
更多解释请参阅此tutorial.
Additional answer to the comment: If your class model specifies the ownership of all association ends, and your class diagram displays them, and there is no ownership dot (nor a navigability arrow), as in , then, according to UML 2.5, the association end is "owned" by the association itself. Since we do neither have an ownership dot at the MyA end, both ends are "owned" by the composite association. In terms of the code to write/generate, this would mean that the composite association is not implemented by means of reference properties in either MyA or MyB, but has to be implemented with the help of a separate class, say "MyA-has-MyB", which has two reference properties for referencing both the aggregate and the component of any composition link, as in the following class rectangle:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)