Java Basics: UML Class Diagram

It is necessary to be familiar with UML class diagrams, which can show the static structure and relationship between classes, interfaces, and them, and can quickly understand the system architecture of others.

The form of the class

In the UML class diagram, you can quickly declare the structure of a class.

Two: the relationship between classes

1. Dependencies

Dependencies are the joins between classes. Dependency means that a class depends on the definition of another class, and only describes a relationship between classes and classes . Dependencies are reflected in the Java language as local variables, method parameters, or Invocation of static methods.

2. Relationship

The connection and association between classes make one class know the properties and methods of another class; usually it contains the meaning of "know" and "understand". Associations can be bidirectional or unidirectional; it can be understood as a class containing instances of another class. For example, a person and his house can use an association relationship;

Regarding the bidirectional association, it can be understood as the association of "student-teacher"

3. Aggregation relationship

Aggregation is a type of association and is a strong association. Aggregation is the relationship between the whole and the individual. For example, the relationship between the car class and the engine class, tire class, and other parts class is the relationship between the whole and the individual. However, the two classes involved in the association relationship are at the same level, while in the aggregation relationship, the two classes are at the unequal level, one representing the whole and the other representing the part.

4. Combination relationship

The biggest difference between the composition relationship and the aggregation relationship is that the part cannot exist without the whole.

5. Generalization relationship

The generalization relationship is the inverse process of the inheritance relationship, the subclass is the inheritance of the parent class, and the parent class is the generalization and refinement of the subclass.

3. Other

1. Implementing the drawing method of the interface

2. Drawing of abstract classes (method class names are in italics)

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325445795&siteId=291194637