Ext.: http://blog.csdn.net/dragonpeng2008/article/details/6836448
In UML class diagrams, the following relationships are common: generalization (generalization), implementation (realization), Association (association), Aggregation (Aggregation), composition (composition), dependency ( Dependency)
1. Generalization (generalization)
Generalization relationship: An inheritance relationship that represents a general and special relationship that specifies how subclasses can characterize all the characteristics and behaviors of a parent class. For example, the tiger is a kind of animal, that is, the characteristics of tigers have animals in common.
Arrow pointing to: Solid line with triangular arrows, arrow pointing to Parent class
2. Implementation (Realization)
Implement relationship: is a class-to-interface relationship that indicates that a class is an implementation of all the characteristics and behaviors of an interface.
Arrow pointing: Dashed line with triangular arrows, arrow pointing to Interface
3. Association (Association)
Association: 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": is the relationship between the whole and the part, and some can leave the whole and exist separately. If the car and the tires are the whole and part of the relationship, the tires leaving the car can still exist.
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, but part cannot leave the whole and exist alone. If the company and the Department is a whole and part of the relationship, no company there is no department.
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 uses a class that requires the assistance of another class, so try not to use two-way interdependence.
"Code representation": 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 = implementation > Composition > Aggregation > Association > dependencies
The following UML diagram shows the various class diagram relationships in a more vivid way:
[UML] Goto: A summary of UML class diagram set relationships