官术网_书友最值得收藏!

Composition

As the name suggests, a class is a composition of another one. This is somewhat similar to aggregation, with the difference being that the dependent class ceases to exist when the main class ceases to exist. For example, a House is made up of a Room, but the Room ceases to exist if the House is destroyed, as shown in the following diagram:

In practice, especially in languages such as Java that have garbage collectors, the boundary between composition and aggregation is not so well defined. Objects are not destroyed manually; when they are no longer referenced, they are automatically destroyed by the garbage collector. For this reason, from a coding point of view, we should not really be concerned if we deal with a composition or an aggregation relationship, but it's important if we want to have a well-defined model in UML.

主站蜘蛛池模板: 定襄县| 方正县| 东乌| 丹棱县| 黄大仙区| 静安区| 云和县| 绍兴县| 中江县| 施秉县| 故城县| 凤阳县| 石狮市| 武陟县| 卢湾区| 鄂托克旗| 右玉县| 荣成市| 盘山县| 阿合奇县| 喜德县| 武夷山市| 龙游县| 疏勒县| 黑水县| 孟州市| 鄂托克旗| 治县。| 教育| 鹤峰县| 承德县| 梓潼县| 化隆| 沙田区| 安化县| 沙雅县| 讷河市| 莱芜市| 潍坊市| 茌平县| 遂溪县|