UML类图中的钻石标志是什么意思? [英] What does a diamond sign signify in UML class diagrams?

查看:228
本文介绍了UML类图中的钻石标志是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑下面的两个图表。顶端包含右端的普通箭头,底部包含一个箭头,左端带有一颗钻石,右侧带有一个普通箭头。

Consider the below two diagrams. The top one contains a plain arrow at the right end, and the bottom one contains an arrow with a diamond at the left end and a plain arrow at the right end. The great book GoF has usages of both of these two kinds of diagrams.

I want to understand what does the diamond signify in the second case, and which one of these two gives a stronger association between Customer and Order.

Is the Customer class responsible for the lifecycle of Order class in either of the two cases?

解决方案

If there is no diamond, then we have a simple association.

If the diamond is left empty, it signifies it is an aggregation. This relation is stronger than a simple association. In this case a Customer aggregates Orders.

If the diamond is black, this means it is a composition, which is even stronger than an aggregation because the aggregated class cannot be aggregated by other classes. Its "life" depends on the container.

I think it's explained a little bit more clearly, at:

这篇关于UML类图中的钻石标志是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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