UML 表示法 - 聚合/组合与“Vanilla"协会 [英] UML Notation - Aggregations/Compositions vs "Vanilla" Associations

查看:31
本文介绍了UML 表示法 - 聚合/组合与“Vanilla"协会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近花了大量时间对我编写的各种软件组件进行详细的 UML 设计.回顾我最近完成的工作并将其与我第一次学习 UML 时进行比较,我发现我现在几乎严格使用聚合和组合关系,并且实际上已经放弃了普通"非定向/定向关系.我当然仍然使用泛化和实现,但这些与上面的明显不同,不属于这个问题的一部分.

I've recently spent a good deal of time performing detailed UML designs of various SW components that I have since written. Looking back on what I have recently finished and comparing that to when I first learned UML, I see that I now almost strictly use Aggregation and Composition relationships, and have virtually abandoned "vanilla" non-directed/directed relationships. I still of course use Generalizations and Realizations, but these are distinctly different than those above and are not considered part of this question.

在我看来,聚合/组合意味着普通"关联的相同含义,等等.聚合和组合自然意味着一个方向,任何现代 UML 程序仍将允许您在聚合/组合关系上定义多重性,并将动词应用于该关系.在这一点上,我认为普通关联没有什么意义.

It seems to me that Aggregation/Composition implies the same meaning of "vanilla" associations, and more. Aggregation and Composition naturally imply a direction, and any modern UML program will still allow you to define multiplicity on an Aggregation/Composition relationship and apply a verb to the relationship as well. At that point, I see little purpose to vanilla associations.

我知道有些人很难理解聚合和组合之间的区别.早些时候,我有点难以理解它们的不同之处,我相信混淆是我使用原版联想的部分原因.我现在认为普通关联很少或没有用处,实际上不喜欢看到它们被使用,因为我相信它们留下了一些问题(特别是两个对象之间的强或弱生命周期关系).我相信普通关联的唯一实际用途是当您对手头问题的理解尚未发展到足以确定聚合和组合之间的生命周期差异时.在这种情况下,最好至少表明存在这种关系,然后当您对手头的问题有了更好的了解时,可以返回并适当地更改它.

I understand some people have difficulty understanding the difference between Aggregation and Composition. Early on, I had a bit of difficult grasping how they differ, and I believe that confusion was part of the reason I used vanilla associations. I'm at the point now where I see little or no use for vanilla associations, and actually dislike seeing them used as I believe they leave some things up for question (particularly a strong or weak lifecycle relationship between two objects). I believe vanilla associations' only practical use is when your understanding of the problem at hand isn't yet developed enough to determine the life cycle difference between aggregation and composition. In such a case it is better to atleast show that the relationship exists and you can then come back and change it appropriately when you have a better understanding of the problem at hand.

长话短说,我相信在人们使用普通联想的绝大多数时间,它们可以更准确地描述为聚合,有时也可以描述为组合.我的信仰是不是大错特错?我错过了什么吗?让我听听!

Long story short, I believe the vast majority of the time that people use vanilla associations, they could be more accurately described as an aggregation, and sometimes as a composition. Am I terribly wrong in my belief? Am I missing something? Let me hear it!

推荐答案

当你说'vanilla associations' 唯一的实际用途是当你还没有理解手头的问题时,你说得有点头疼开发到足以确定生命周期差异表明存在这种关系,然后当您更好地了解手头的问题时,您可以返回并适当地更改它.

UML 元模型 将聚合和组合定义为关联的扩展.一个关联可以被认为是域对象之间的一种未细化的关系,就像一个域对象是一个未细化的类一样.我通常在领域建模阶段使用简单的关联,并在解析详细的类模型时将其细化为组合或聚合.

The UML Meta-Model defines Aggregation and Composition as extensions of Association. An Association can be considered an unrefined relationship between domain objects, in the same way that a Domain object is an unrefined Class. I typically use simple Associations at the Domain Modelling stage and refine it into either Composition or Aggregation as appropriate when I resolve the detailed Class Model.

这篇关于UML 表示法 - 聚合/组合与“Vanilla"协会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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