聚集:死后还是不死? [英] Aggregation: Life after death or no?

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

问题描述

我一直在阅读一些有关组织的堆栈溢出的文章,以及它如何与委托和组合进行比较。主要是:



区分代理,组合和聚合(java OO设计)



根据我在这里阅读的这篇文章和其他文章,让步是聚合是一个对象拥有另一个对象,然而,一个对象的死亡并不意味着另一个对象的死亡。然而,根据GoF的设计模式:



聚合意味着聚合对象及其所有者具有相同的寿命[底部的第22页]



对此有任何建议?



谢谢

解决方案

我已经看过这两种定义,但已经建立的定义似乎是:





  • 聚合意味着没有共享的生命周期



IIRC,这是UML中使用的含义。 p>

I have been reading a couple of articles on stack overflow about aggreation and how it compares to delegation and composition. Mainly:

distinguishing between delegation, composition and aggregation (java OO design)

According to this and other articles I have read on here, the concession is that aggregation is that one object owns another, however, the death of one does not mean the death of the other. However, according to Design Patterns by the GoF:

"Aggregation implies that an aggregate object and its owner have identical lifetimes" [page 22 on the bottom]

Any advice on this?

Thanks

解决方案

I've seen both kinds of definitions, but the established ones seem to be:

  • composition implies shared lifetime
  • aggregation implies no shared lifetime

IIRC, that's the meaning used in UML.

这篇关于聚集:死后还是不死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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