UML聚集VS协会 [英] UML aggregation vs association

查看:127
本文介绍了UML聚集VS协会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里,大约聚集和关联另一个问题。我想学习UML的一些基础知识,所以我就开始由Martin Fowler阅读UML精粹。我读班两章,有一件事,我不能完全掌握,我认为,这是聚集VS关联。在这本书中有这样的话:

Here I am, with another question about aggregation and association. I wanted to learn some basics of UML, so I started reading "UML distilled" by Martin Fowler. I read both chapters about classes, and there is one thing that I can't fully grasp I think, and that is aggregation vs association. In the book there is this quote:

在pre-UML天,人们通常是对什么是聚集相当含糊,什么是
  协会。无论模糊与否,他们总是与其他人不一致。结果是,
  许多建模认为聚集是非常重要的,因为不同的原因,虽然。因此,UML
  包括聚集(图5.3),但几乎没有任何语义。正如吉姆·鲁博说,​​想想吧
  作为建模安慰剂的 [鲁博,UML参考。

In the pre-UML days, people were usually rather vague on what was aggregation and what was association. Whether vague or not, they were always inconsistent with everyone else. As a result, many modelers think that aggregation is important, although for different reasons. So the UML included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Think of it as a modeling placebo" [Rumbaugh, UML Reference].

当我从这段话,而我对堆栈溢出阅读主题的理解并不重要的这两个关系我用一个,他们的意思是bassicly一样的,或者是有任何情况下聚合,而不是协会的用法会是合理的和/或我不能改变一个到另一个而不改变一类图的意义?

As I understand from this quote and topics that I read on Stack Overflow it doesn't matter which one of those two relations I use, they mean bassicly the same, or is there any situation where the usage of aggregation instead of association would be justified and/or I could not change one to the another without changing the "meaning" of a class diagram?

我问这个,怎么一回事,因为这本书是从2003年,有些事情可能在那几年中改变。

I am asking this, beacuse this book is from 2003, and some things could change during those few years.

推荐答案

鲁博的语句是最有说服力和Uncle Bob的好建议。正如我已经说过<一个href=\"http://stackoverflow.com/questions/7834052/uml-class-diagram-association-vs-aggregation-composition-diamonds/7836357#7836357\">elsewhere,聚集在语义上很弱,没有提供实际有益的。它只有一个有效的角落情况下(递归关系acyclicity),但是很少有人知道,明白。所以,你最终不得不在评论反正指出。

Rumbaugh's statement is the most telling and Uncle Bob's good advice. As I've said elsewhere, Aggregation is semantically so weak as to offer nothing practically beneficial. It only has one valid corner case (acyclicity of recursive relationships) however few people know and understand that. So you end up having to point out in comments anyway.

我不使用它。而从未感到任何损失。用简单的二元关联坚持并专注于真正重要的事情 - 获得基数和冠名权。你会得到更从比试图决定不可判定关联与聚集。

I just don't use it. And have never felt any loss. Stick with simple binary associations and focus on what really matters - getting the cardinality and naming right. You'll get far more from that than trying to decide the undecidable association vs. aggregation.

心连心。

这篇关于UML聚集VS协会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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