`
d02540315
  • 浏览: 31389 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

Aggregation v.s. Composition

UML 
阅读更多
Aggregation

Aggregation is a kind of association that specifies a whole/part relationship between the aggregate (whole) and component part. This relationship between the aggregate and component is a weak “has a” relationship as the component may survive the aggregate object. The component object may be accessed through other objects without going through the aggregate object. The aggregate object does not take part in the lifecycle of the component object, meaning the component object may outlive the aggregate object. The state of the component object still forms part of the aggregate object.

An example of aggregation is a History-Class object contains zero or more of Student objects. The state of each Student object has an influence on the state of the History-Class object. If the History-Class object is destroyed, the Student objects may continue to exist.




The UML diagram above illustrates the aggregation association line with an open diamond on the aggregate side.

Composition

Composition is a kind of association very similar to aggregation except where the composite object has sole responsibility for the disposition of the component parts. The relationship between the composite and the component is a strong “has a” relationship, as the composite object takes ownership of the component. This means the composite is responsible for the creation and destruction of the component parts. An object may only be part of one composite. If the composite object is destroyed, all the component parts must be destroyed, or the reference and responsibility of the component part must be handed over to another object. Composition enforces encapsulation as the component parts usually are members of the composite object.

An example of composition is a House object contains zero or more Room objects. The state of each Room object has an influence on the House object. If the House object is destroyed, the Room objects will also be destroyed.




The UML diagram above illustrates the composition association line with a solid diamond on the composite side.
  • 大小: 4.5 KB
  • 大小: 4.2 KB
分享到:
评论

相关推荐

    PHP手册(带评论版-2008-03-14).part2.rar

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    PHP手册(带评论版-2008-03-14).part1.rar

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    php中文完全开发手册

    Object Aggregation/Composition Functions LXXIV. Oracle 8 函数库 LXXV. OpenSSL Functions LXXVI. Oracle 函数库 LXXVII. Ovrimos SQL Functions LXXVIII. 输出控制函数 LXXIX. Object property and method call...

    php手册.chm,php手册

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    PHP函数参考手册大全

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    中文版PHP使用手册

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    php手册PHP5研究室编无乱码版本chm

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL ...

    经典收藏最全php5.0查询手册

    Object Aggregation/Composition Functions XCII. Object property and method call overloading XCIII. ODBC and DB2 functions (PDO_ODBC) XCIV. ODBC Functions (Unified) XCV. oggvorbis XCVI. OpenAL Audio ...

    PHP5 开发手册 简体中文手册

    Object Aggregation/Composition Functions XCIV. Object property and method call overloading XCV. Oracle 函数 XCVI. ODBC Functions (Unified) XCVII. ODBC and DB2 functions (PDO_ODBC) XCVIII. oggvorbis ...

    PHP官方手册中文版

    Object Aggregation/Composition Functions CVI. Object property and method call overloading CVII. Oracle 函数 CVIII. ODBC Functions (Unified) CIX. ODBC and DB2 Functions (PDO_ODBC) CX. oggvorbis ...

    PHP手册2007整合中文版

    Object Aggregation/Composition Functions CVI. Object property and method call overloading CVII. Oracle 函数 CVIII. ODBC Functions (Unified) CIX. ODBC and DB2 Functions (PDO_ODBC) CX. oggvorbis CXI. ...

    php帮助文档,php。chm,php必备的中文手册

    Object Aggregation/Composition Functions XCV. Object property and method call overloading XCVI. Oracle 函数 XCVII. ODBC Functions (Unified) XCVIII. ODBC and DB2 functions (PDO_ODBC) XCIX. oggvorbis C...

    Writing GNOME Applications

    7. AGGREGATION WITH INDEPENDENT WORKS 8. TRANSLATION 9. TERMINATION 10. FUTURE REVISIONS OF THIS LICENSE Addendum List of Figures 2-1. Singly and Doubly Linked Lists 2-2. Structure of a Hash Table 2-3...

Global site tag (gtag.js) - Google Analytics