- 浏览: 32510 次
- 性别:
- 来自: 杭州
-
最近访客 更多访客>>
最新评论
-
bbym010:
通俗易懂,不错
Build模式的理解 -
0000ps:
今天在MSDN上看到一段内容:
Value Object. S ...
Value Object vs. Data Transfer Object (VO vs. DTO)
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.
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.
发表评论
-
Facade vs Proxy
2010-04-02 08:36 1231Question: i feel there is not m ... -
UML中关联(association)和依赖(dependency)的区别
2010-03-30 08:56 3277这个问题不仅我们这些小喽罗会迷惑,很多大拿们也没有统一的认识, ... -
UML中几种类间关系:继承、实现、依赖、关联、聚合、组合
2009-12-06 23:13 1265继承,泛化(Generalization) 指的是一个类( ... -
Build模式的理解
2009-11-26 23:23 2215Builder模式 是为了将构建复杂对象的组装过程和它的创建部 ... -
设计模式简图
2009-11-26 22:00 890... -
Proxy, Builder and Decoration 异同点
2009-11-09 13:52 0晚上写分打发打发法 -
面向对象设计原则
2009-11-07 09:43 729正如牛顿三大定律 ... -
Flyweight Pattern 享元模式
2009-09-29 16:07 908GOF:运用共享技术有效地支持大量细粒度的对象。 解释一 ... -
Using the Prototype pattern to clone objects
2009-09-27 15:48 924Prototype pattern is one of the ... -
Is a Java Immutable Class Always final?
2009-09-27 15:10 1544In response to my recent blog p ... -
Defensive copying
2009-09-27 14:46 1003A mutable object is simply an o ... -
Copy constructors
2009-09-27 14:29 821Copy constructors : provi ... -
Immutable objects
2009-09-27 14:13 879Immutable objects are simply ob ... -
Java Immutable Class
2009-09-27 14:09 2012Java Immutable Class[ From ] ... -
Value Object vs. Data Transfer Object (VO vs. DTO)
2009-09-18 10:31 1662The pattern which is known toda ...
相关推荐
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 ...
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 ...
Object Aggregation/Composition Functions LXXIV. Oracle 8 函数库 LXXV. OpenSSL Functions LXXVI. Oracle 函数库 LXXVII. Ovrimos SQL Functions LXXVIII. 输出控制函数 LXXIX. Object property and method call...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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. ...
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...
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...