Basic symbols of a similar graph can be split into dotted lines, arrows, solid lines, hollow right triangles, solid right triangles, hollow diamond and solid diamond. These basic graphs are combined to form the basic symbols of the class graph. The order of these symbols represents the Coupling Degree between classes. The greater the coupling, the higher the coupling.
The dotted line + arrow indicates the dependency, the solid line + arrow indicates the association, the dotted line + the hollow right triangle indicates implements, and the solid line + the hollow right triangle indicates generalization, that is, the inheritance relationship of the class. Solid line + hollow diamond represents the aggregation relationship, and solid line + solid diamond represents the combination relationship.
Note the following when viewing a class chart. In fact, the idea of class diagrams has not been separated from the object-oriented idea. Taking a class as the center, some lines are injected and some lines are shot. The injection line indicates the classes called by the class, and the injection line indicates the classes called by the class, including generalization, association, dependency, aggregation, and combination. This is similar to the description of the graph in discrete mathematics.
1. Class: It is represented by a three-layer rectangle.
The first layer displays the class name. If it is an abstract class, it is displayed in italic.
The second layer is fields and attributes.
The third layer is the class method.
Note that '+' indicates public, '-' indicates private, and '#' indicates protected.
2. Interface: the interface is represented by a two-layer rectangle. The main difference between the interface and the class chart is that the top is displayed <interface>.
The first line is the interface name.
The second line is the interface method.
3. Inheritance class (extends): Expressed by a hollow triangle + solid line.
4. Implemented interfaces (implements): Expressed by a hollow triangle + dotted line
5. Association): Expressed by solid arrows, such as swallow and climate
6. Aggregation): Expressed by hollow diamond + solid arrow
Aggregation: indicates a weak 'owner' relationship. It indicates that object A can contain object B, but object B is not part of object A, such as company and employee.
Composition: Expressed by solid diamond + solid arrow
Combination: the relationship between parts and the whole, and the lifecycle is the same. Example: People and hands
7. Dependency): Expressed by dotted arrows, such as animals and oxygen
8. BaseThe numbers at both ends of the line indicate that the class at the end can have several instances. For example, a bird should have two wings. If a class may contain multiple instances, it is represented by 'n. Association, aggregation, and combination have a base.