Summary of several relationships of UML class diagrams

Source: Internet
Author: User
Tags dashed line

in theUMLin class diagrams, the following relationships are common:Generalization (Generalization),  implementation (Realization),Association (Association),Aggregation (Aggregation), combination (composition), dependent (Dependency)

1. Generalization (generalization)

"Generalization relationship": An inheritance relationship , It specifies how subclasses can characterize all the characteristics and behaviors of a parent class . For example: Tigers are a kind of animal .

Arrow pointing to: Solid line with triangular arrows, arrow pointing to Parent class

2. Implementation (realization)

"Implementing Relationships": is a class-to-interface relationship that indicates that a class is an implementation of all the characteristics and behavior of an interface

Arrow pointing: Dashed line with triangular arrows, arrow pointing to Interface

3. Association (association)

" Association Relationship ": is an owning relationship that enables a class to know the properties and methods of another class; such as: teachers and students, husbands and wives

Associations can be bidirectional or unidirectional. Two-way associations can have two arrows or no arrows, and one-way associations have an arrow.

"Code embodiment": member variable

Arrows and points: solid lines with normal arrows, pointing to the owner

, teachers and students are two-way association, the teacher has many students, students may also have more than one teacher. But the relationship between a student and a course is a one-way link, a student may have to take many courses, the course is an abstract thing he does not own students.

To associate itself with:

4. Aggregation (Aggregation)

"Aggregation relationship": the relationship between the whole and the part . if the car and tyre are the whole and part of the relationship .

The aggregation relation is one kind of association relation, is the strong association relation, the Association and the aggregation cannot distinguish syntactically, must examine the concrete logical relation.

"Code embodiment": member variable

"Arrows and points": solid lines with hollow diamonds, diamonds pointing to the whole

5. Combination (composition)

"Combinatorial relationship": the relationship between the whole and the part . , Without a company, there's no division. a combinatorial relationship is a relationship that is stronger than the aggregation relationship, which requires that an object representing the whole in an ordinary aggregation relationship be responsible for the life cycle of the object representing the part.

"Code embodiment": member variable

Arrows and points: solid lines with solid diamonds, diamonds pointing to the whole

6. Dependency (Dependency)

"dependency": a relationship that is used , so try not to use two-way interdependence.

"Code Performance" : A local variable, a parameter to a method, or a call to a static method

Arrows and points: dashed lines with arrows pointing to the user

The order of strength of the various relationships:

Generalization= Implement>Combination>Aggregation>Associate>Dependent

The following UML diagram shows the various class diagram relationships in a more vivid way:



From for notes (Wiz)



Summary of several relationships of UML 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.