The difference between aggregation and composition:
1. The aggregation relationship is also called "has-a" relationship, and the combinatorial relation is also called "contains-a" relationship.
2. The aggregation relation represents the weaker situation of the whole/part relation of the thing, and the combination relation indicates the strong situation of the whole/partial relationship of the thing.
3. In the aggregate relationship, the representative of something can belong to more than one aggregation object, can be shared for multiple aggregate objects, and can change the aggregation object it is subordinate to at any time. Objects representing part of the object have nothing to do with the lifetime of the objects that represent the aggregate object, The object representing some of the things is not necessarily deleted. In a combinatorial relationship, the object representing the whole thing is responsible for creating and deleting objects that represent parts of things, and representing parts of things that belong to only one composite object. Once the grouped object is deleted, the corresponding object that represents some of the things is deleted.
For example, you might know better:
Aggregation (Aggregation):-----has a---------------people own computers
An object that represents something in an aggregation relationship has nothing to do with the lifetime of the object that represents the aggregation, and once the aggregate object is deleted, the object representing the part is not necessarily deleted.
Combination (composition):----Contains A----------people are made up of hands, feet, faces, etc.
Once the grouped objects are deleted in the combination, the object representing some of the things is deleted.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service