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

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.

主站蜘蛛池模板: 涿鹿县| 镇远县| 蓬安县| 皮山县| 承德县| 孟连| 崇礼县| 张家口市| 普格县| 武穴市| 郎溪县| 东乡县| 瓦房店市| 邢台市| 合川市| 阜南县| 通道| 三门县| 电白县| 白沙| 古田县| 叙永县| 台南市| 五大连池市| 湘西| 教育| 长乐市| 筠连县| 阿克| 沙田区| 丹东市| 乌拉特后旗| 隆子县| 宜良县| 滦南县| 安国市| 巨鹿县| 个旧市| 罗甸县| 莲花县| 闵行区|