[UML] Summary of several types of Class Diagrams

Source: Internet
Author: User

In a UML diagram, there are several common relationships: generalization, implementation, association, aggregation, and composition ), dependency)

1. Generalization)

[Generalized relationship]: an inheritance relationship that specifies how child classes feature all features and behaviors of the parent class. For example, a tiger is an animal.

[Arrow pointing]: solid line with a triangular arrow. the arrow points to the parent class.


2. Implementation)

[Implementation relationship]: The relationship between a class and an interface, indicating that a class is the implementation of all features and behaviors of an interface.

[Arrow pointing]: dotted line with a triangular arrow. the arrow points to the interface.

3. Association)

Association Relationship: a relationship that enables a class to know the attributes and methods of another class. For example, a teacher and a student, a husband and a wife

The association can be bidirectional or unidirectional. Two-way association can have two arrows or no arrows, and one-way Association has one arrow.

[Code embodiment]: member variables

[Arrow and direction]: solid line with a normal arrow, pointing to the owner

There is a two-way relationship between teachers and students. Teachers have multiple students, and students may also have multiple teachers. However, the relationship between a student and a course is one-way association. A student may have to take multiple courses. The course is an abstract thing and he does not have any students.

Associate yourself

4. Aggregation)

[Aggregation relationship]: The relationship between the whole and the part. For example, the relationship between the car and the tire is the relationship between the whole and the part.

An aggregation relationship is a strong association relationship. The association and aggregation cannot be distinguished in syntax, and the specific logical relationship must be investigated.

[Code embodiment]: member variables

[Arrow and direction]: solid line with hollow diamond. The diamond points to the whole.

5. Composition)

[Composite relationship]: The relationship between the whole and the part ., without a company, there is no department composite relationship. This is a type of association relationship, which is stronger than the aggregation relationship, it requires that the object representing the whole in a common aggregation relationship be responsible for representing the lifecycle of some objects.

[Code embodiment]: member variables

[Arrow and direction]: solid line with solid diamond. The diamond points to the whole.

6.Dependency)

[Dependency]: it is a type of use relationship. Therefore, do not use bidirectional dependency whenever possible.

[Code representation]: local variables, method parameters, or calls to static methods

[Arrow and direction]: a dotted line with an arrow pointing to the user

 

 

 

Strong and weak order of various links:

Generalization = implementation> combination> aggregation> association> dependency

 

 

 

The following UML diagram visually shows the relationship between different types of diagrams:

 

Reference http://blog.csdn.net/tianhai110/article/details/6339565

 

[UML] Summary of several types of Class Diagrams

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.