Third, class diagram
The class diagram is a diagram showing class, interface, and static structure and relationship thereof. The basic element of the class diagram is class or interface.
The box can be divided into several layers
Class name properties list method list nature list
If a class has an internal member class, then its class diagram will have 5 floors. In the class diagram, other layers can be omitted in UML except that the class name cannot be omitted.
The first layer is a class name. If the class name is a statue, it indicates that the class is specific (CONCRETE, that is, instantiated), if the variable name is behind, indicating that the class is abstract.
The second layer is attribute layer. If there is a number left, it indicates that it is public; if there is one -, it indicates that it is private; if there is #, it indicates protected.
The third layer is a method layer. The integrated and attribute layer of - #.
Method Below if there is an underscore, it indicates that it is a static method.
The fourth layer is a nature layer, which is a structure consisting of an attribute, an internal variable, an assignment function, and a value of value. E.g:
Public String Class1 {
PRIVATE STRING JOBTITLE
Public string getjobtitle () {
Return jobtitle;
}
Public string setjobtitle (String jobtitle) {
THIS.JOBTILE = JobTitle;
}
}
In the UML diagram, the upper left corner of the class is usually divided into two lines of parent class and the implemented interface.
1, describe the class diagram of the interface
The class diagram of the interface is almost the same, the only difference is the name of the interface with an "interface".
An interface does not have nature, there may be a declaration, public and final static interior members of the PUBLIC and FINAL.
2, describe the class diagram of the object
The object map is a special class diagram, which is not a class, but an instance of a class. The object map is very useful when there is a structure in which the recursive relationship is displayed, especially the structure of the recursive relationship.
In the object map, each rectangle represents an instance. The names of the instance are underlined, which can distinguish between a rectangle or an object. As long as the meaning of the figure is clear, the name or class of the object can be omitted from the figure.
3, the relationship in the class diagram
Between classes and classes, there will be links to indicate their relationships. Category and classes, classes, and interfaces, interfaces and interfaces can be established: generalization relationship, association relationship, aggregation relationship, synthetic relationship and dependencies. These relationships are static.
(1) Generalization relationship represents the inheritance relationship between classes and classes, inheritance relationship between interfaces and interfaces, or realization relationship between classes. The generalization relationship is to point to the parent class from the subclass, or the interface to which the interface is implemented, the inheritance or the direction of the implementation.
The general relationship is often directly translated into keywords Extends and Implements. The former represents the direct inheritance relationship between classes and class, the rear of the interface and the interface.
(2) Association relationship showing the link between classes and classes, which makes a class to know the properties and methods of another class. The association can be two-way or one-way. The two-way association can have two arrows or no arrows. One-way association has an arrow indicating the direction of the associated. One-way association is more common, usually do not encourage bidirectional associations.
Each association has two endpoints, each endpoint can have a role name, display the essence of the associated. An association can have a direction arrow indicating the direction of traversal or query.
At each associated endpoint, there can be a MutiPlicity, indicating that the class of this end can have several instances.
Note: A relationship is often further determined as a polymerization relationship or a partnership. I am tired of typing, I don't write so much in the future, I will write about writing.