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

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.

主站蜘蛛池模板: 澄迈县| 莒南县| 阳新县| 西昌市| 大姚县| 格尔木市| 江阴市| 准格尔旗| 台东市| 城固县| 延庆县| 文登市| 克东县| 上饶市| 页游| 白银市| 冷水江市| 永春县| 潞西市| 土默特左旗| 华池县| 宜良县| 连云港市| 安西县| 光山县| 凤庆县| 浪卡子县| 寻甸| 呼伦贝尔市| 彭泽县| 新乡县| 万山特区| 时尚| 东城区| 搜索| 开阳县| 雷州市| 乐至县| 怀集县| 台东县| 岑溪市|