聚合和可导航性在同一端 [英] Aggregation and navigability at the same end

查看:121
本文介绍了聚合和可导航性在同一端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UML中,是否可以在组件对象可以访问复合对象的地方绘制一个聚合?就像这张图片一样,但是只有一条关联线,因此关联端点触摸A会带有菱形和箭头. 如果这不可能,那么我绘制的图表是否有效?如果没有,为什么?

In UML, is it possible to draw an aggregation where the component object can access the composite object? Like in this image, but with only one association line, so the association end touching A would have a diamond and an arrow. If that isn't possible, the diagram I drawn is valid? If not, why?

推荐答案

从另一个角度来看,可导航性对于显示如何在模型中导航以及如何访问实例很重要.

Another point of view, navigability is important to show how is it possible to navigate in the model and how to access to instances.

关于OCL的另一点是,如果未定义可导航性,则某些OCL查询将很难编写.

Another point is about OCL, if navigability is not defined some OCL queries will be hard to write.

规范描述(p 198):可导航性意味着可以从关联另一端的实例有效地访问运行时参与链接的实例(关联的实例).实现这种有效访问的精确机制是特定于实现的.如果一端不可导航,则可能会或可能不会从另一端进行访问,如果可以,则可能效率不高.

Specification describes (p 198): Navigability means that instances participating in links at runtime (instances of an Association) can be accessed efficiently from instances at the other ends of the Association. The precise mechanism by which such efficient access is achieved is implementation specific. If an end is not navigable, access from the other ends may or may not be possible, and if it is, it might not be efficient.

关于Property类(p 149):查询isNavigable()指示是否可以在该属性上导航.正文:不是classifier-> isEmpty()或association.navigableOwnedEnd-> includes(self).

And about Property class (p 149): The query isNavigable() indicates whether it is possible to navigate across the property. body: not classifier->isEmpty() or association.navigableOwnedEnd->includes(self).

因此,对可导航性进行建模或不进行建模很重要.

So to model or not navigability is important.

如果您想在两面都具有导航性,下图显示:

If you want to have navigability in both side, the following image shows that:

但是在规范的第6节中,它写为:

But in section 6 of the specifiation, it is written:

  • 两端都没有用可导航性箭头标记的关联意味着该关联在两个方向上都是可导航的.

  • An association with neither end marked by navigability arrows means that the association is navigable in both directions.

箭头符号用于表示关联端点的可导航性.根据定义,所有类拥有的关联端点都是可导航的.按照惯例,元模型中所有关联拥有的末端都是不可导航的.

Arrow notation is used to denote association end navigability. By definition, all class-owned association ends are navigable. By convention, all association owned ends in the metamodel are not navigable.

因此,以下架构与上面的架构相同.这很棘手,但似乎是事实.

So the following schema is the same than the above one. This is tricky but it seems true.

这篇关于聚合和可导航性在同一端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆