Correlation, composition, aggregation, dependency comparison

Source: Internet
Author: User

Types of relationships between classes: generalization (generalization ),Dependency (Dependency ),Association (Affinity), Aggregation ( Aggregation relationships) ,composition (synthetic relationships ).
where Aggregation (aggregation relation) ,composition (synthetic relation) belong to Association (association relation ), is special Association the associated relationship. generalization (generalization ) is represented as an inheritance or implementation relationship (is a). The concrete form is the inheritance relation between the class and the class, the inheritance relation between the interface and the interface, and the implementation relation of the class to the interface.


Association correlation is represented as a variable(Has a). A join between a class and a class that enables a class to know the properties and methods of another class. For example, ifA relies onB, thenb is reflected inThe global variable of a. Association relationships have two-way associations and one-way associations. Bidirectional affinity: Two classes are aware of the public properties and operations of another class. One-way Association: Only one class knows the public properties and operations of another class. Most associations should be unidirectional, one-way relationships easier to establish and maintain, and help find classes that can be taken.



Aggregat Ion (Aggregation relationship) is a kind of association relationship, is a strong association. 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 part. At the same time, it is a weak "owning" relationship. Reflects theA object can containB object, butThe B object is nota object. Specifically, if a by b poly Synthesis, the performance of a contains b of global objects, but the Span lang= "en-US" >b objects can not be created at the moment a was created. The



    composition (Combinatorial relationship composition (Combinatorial relationship a is made up of b, the a contains global objects with b, and b objects are created at the moment a was created. The


dependency (dependency a relies on b, then b is represented as a local variable, a method's parameter, or a static method call.


/span>

Affinity, composition, aggregation, dependency comparison

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.