Aggregation and navigability at the same end

后端 未结 2 548
故里飘歌
故里飘歌 2021-01-15 04:33

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 asso

2条回答
  •  借酒劲吻你
    2021-01-15 05:35

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

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

    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.

    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:

    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.

提交回复
热议问题