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

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.

主站蜘蛛池模板: 凉城县| 安达市| 宜宾县| 六枝特区| 南乐县| 文成县| 张掖市| 平原县| 双辽市| 普兰县| 丰顺县| 绥滨县| 长宁县| 巴彦淖尔市| 新宁县| 建水县| 金华市| 长沙县| 高要市| 华池县| 清苑县| 西昌市| 石渠县| 贺兰县| 磐石市| 古丈县| 栖霞市| 海城市| 栖霞市| 托克托县| 屏东县| 温宿县| 濮阳县| 舟山市| 买车| 贵德县| 德钦县| 姚安县| 博爱县| 门头沟区| 麻阳|