Aggregation or composition relationships are used if an object of one class is contained in an object of another class.
They are drawn as a line with a diamond at the end of the containing class. A composition relationship’s diamond is filled; an aggregation’s diamond is not.
The difference between these two kinds of relationships is as follows: The contained element in a composition relationship is a part of the containing element: If the containing element is deleted, the contained element no longer exists. Therefore, composition means an object may only be contained in one other object.. An aggregation relationship is one of shared objects. This means, multiple objects may aggrgate the same object. By consequence, an aggregated object still exists, even if the aggregating object is deleted
If the PERSON no longer exists, nor do the feet. In contrast, a PERSON may also have a lot of COATs. However, a COAT may generally be used by multiple PERSONs and its life-cycle is generally independent of the life-cycle of its wearers.
An association relationship has weaker semantics than the composition relationship. Here, both objects have “equal
rights”. An association relationship opens visibility onto the attributes of the related objects. Figure 9 gives an example of an association. In an association objects of one class may be related to one or more objects of the other class. To restrict the number of associations of the same type between two classes, cardinalities are used in the same way as for compositions.
An Association class is a hybrid of an association and a class. Generally, they can be interpreted as an association carrying its own attributes (and methods). They are drawn like an association with a class symbol being connected to the centre of the association line with a dashed line
{xor} constraint: It enforces that an instance of one class has a relationship with instances of one or the other associated class but never both at the same time.
In this paragraph, a very short idea of how the UML model is mapped onto XML language elements is given. It does not claim do be complete
本文探讨了UML中聚合与组合关系的区别,强调了这两种关系如何定义类之间的包含关系。组合关系下,当容器对象被删除时,其内部元素也将不复存在;而聚合关系则允许多个对象共享同一元素,即使容器对象被删除,共享元素仍可存在。此外,还介绍了关联关系及其与组合关系的不同之处。
320

被折叠的 条评论
为什么被折叠?



