Correlation, composition, aggregation, dependency ratio

Source: Internet
Author: User

The relationships between classes

1. Type:Generalization (Generalization),Dependency (Dependent Relationships),Association (Association Relationship),Aggregation (Aggregation Relationships),Composition (Synthetic Relationships).

2.   amongAggregation (Aggregation Relationships),Composition (Synthetic Relationships)belong toAssociation (Association Relationship), is a specialAssociationThe Association relationship.

3. generalization ( generalization ) is represented as an inheritance or implementation relationship (is a). The detailed form is the inheritance relationship between the class and the class, the inheritance relationship between the interface and the interface, and the implementation relationship of the class to the interface.

4.   AssociationAssociation relationships behave as variables(has a). A join between a class and a class that enables a class to know about the properties and methods of a class. Suppose, for example ,Arelies onB, youBembodied asAGlobal variables. Association relationships have two-way associations and one-way associations. Bidirectional correlation: Two classes know that there is also a class of public properties and operations. One-Way Association: There is only one class that knows the public properties and operations of a second class. Most associations should be unidirectional, and one-way relationships easier to build and maintain, helping to find classes that can be taken.

5.   Aggregation (Aggregation Relationships) is a kind of association relation, is a strong association relation. The aggregation relationship is the relationship between the whole and the individual. The two classes of the common relational relationship are at the same level, while the two classes of the aggregation relationship are at different levels, one is the whole and the other is the part. At the same time, it is a weak "owning" relationship. Reflects theAobjects can includeBobject, butBobject is notAthe component of the object. In detail, supposeAbyBPoly-Synthesis, expressed asAinclude aBthe global object, butBobject can not beACreated at the moment of creation.

6.   Composition (Combinatorial Relationships)is a kind of correlation relation, is stronger than the aggregation relationship. It requires that the object representing the whole in a common aggregation relationship be responsible for the life cycle of the object that represents the part. Composition (Combinatorial Relationships)is a strong "own" relationship, reflecting the strict part and the overall relationship, part and the overall life cycle is consistent. AssumptionsAbyBcomposition, expressed asAinclude aBthe Global object, andBobject inACreated at the moment of creation.

7.   Dependency (Dependent Relationships)represented as a parameter in a function(use a). is a connection between a class and a class, which means that a class depends on the definition of a class, and that the change of one class affects the other class. Suppose, for example ,Arelies onB, youBrepresented as a local variable, a method's argument, or a call to a static method.

8. Helios 2008-1-11

Correlation, composition, aggregation, dependency ratio

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.