Unified Modeling Language (UML), also known as the Unified Modeling language or standard modeling language, was an OMG standard that began in 1997 as a graphical language that supports modeling and software development, providing modeling and visualization support for all phases of software development, Includes requirements analysis to specifications, to construction and configuration. The development of object-oriented analysis and Design (ooa&d,ooad) has a climax in the late 80 to 90, and UML is the product of this climax. It not only unifies the representation method of Booch, Rumbaugh and Jacobson, but also develops it further, and finally unifies the standard modeling language accepted by the public.
In UML class diagrams, several commonly used relationships are: generalization (generalization), implementation (realization), Association (association), Aggregation (Aggregation), combination (composition), dependency ( Dependency), next, through this article to all of you to do a detailed explanation, the specific details are as follows:
1. Generalization (generalization)
Generalization relationships: An inheritance relationship that represents a general and special relationship that specifies how subclasses can characterize all the characteristics and behavior of the parent class. For example: Tigers are a kind of animals, that is, the characteristics of tigers and animals are common.
"Arrow pointing": Solid line with triangular arrow, arrow pointing to Parent class
2. Implementation (Realization)
"Implementing relationship" is a relationship between a class and an interface, which means that the class is an implementation of all the characteristics and behaviors of the interface.
"Arrow pointing": Dotted 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; teachers and students, husbands and wives
The association can be bidirectional or one-way. A two-way association can have two arrows or no arrows, and a one-way association has an arrow.
"Code embodiment": member variables
"Arrows and points": solid lines with normal arrows, pointing to the owner
In the picture above, the teacher and the student is the two-way association, the teacher has many students, the student may also have many teachers. But the relationship between a student and a course is a one-way link, a student may have to take a number of courses, the course is an abstract thing he does not own students.
The image above is associated with itself:
4. Polymerization (Aggregation)
"Aggregation relationship": is the whole and part of the relationship, and part can leave the whole and exist alone. If the car and tyre are integral and part of the relationship, the tires can still be left in the car.
The aggregation relation is one kind of correlation relation, is the strong correlation relation, the association and the aggregation cannot differentiate in the grammar, must examine the concrete logical relation.
"Code embodiment": member variables
Arrows and points: a solid line with a hollow diamond, with a diamond pointing to the whole
5. Combination (composition)
"Combinatorial relationship": it is the relationship between the whole and the part, but the part cannot leave the whole and exist alone. If the company and the Department are the whole and part of the relationship, no company does not exist in the department.
The combinatorial relation is one kind of association relation, is the relation which is stronger than the aggregation relation, it requires the ordinary aggregation relation to represent the whole object to be responsible for representing part of the life cycle of the object.
"Code embodiment": member variables
"Arrows and points": solid lines with solid diamonds, rhombic to Whole
6. Dependence (Dependency)
Dependencies: A use of a relationship in which the implementation of a class requires assistance from another class, so try not to use bidirectional interdependence.
"Code representation": A local variable, a parameter to a method, or a call to a static method
"Arrows and points": dotted lines with arrows pointing to the user
The strong and weak sequence of relationships:
Generalization = implementation > combination > Aggregation > Association > Dependency
The following UML diagram illustrates the various class diagram relationships in a more figurative way:
The above content is the entire narration of this article, Hope everybody likes.