Representation of a class diagram

We can see that the class diagram uses a rectangle to represent our class. The class name is at the top, the property is in the middle, and the method is at the bottom.

attribute

We can see the plus and minus signs in front of the property, which are used to indicate the visibility of the property or method.

“+” indicates public, and “-” indicates private

The equals sign after a property is used to indicate the default value of the property.

Visibility name: type [= default]

methods

Visibility name (argument list) [: Return type]

The return type can be writable or writable

For example, operation2 in the figure above does not write the return parameters, but it is recommended to write both if possible

Relationships between classes

Five kinds of relationship and the corresponding class drawing method need to master, here is mainly the line drawing method need to master.

After the line is selected in Processon’s page, you can select the start and end point of the line in the toolbar above.

correlation

Association can be divided into unidirectional association and bidirectional association.

One-way link

The individual association is represented by A straight line with an arrow, indicating that A holds B.

The figure above represents a one-way association where a user has multiple contact addresses to choose from when placing an order.

Bidirectional association

Each party holds A member variable of the other type, that is, A has B in it and B has A in it. This makes sense. Nugget users have written a lot of articles, and the articles have received a lot of likes.

If we could figure out the relationship between the two, calculating malicious likes would be very simple.

dependencies

The dependency is represented by A dotted line with an arrow, indicating that A must need B to function. Methods embodied in one class take an object of another class as an argument.

Generalization relationship

A straight line with a hollow triangle is used to indicate the relationship between the parent class and the child class. It is also called inheritance.

Cars and bicycles are subclasses of the vehicle parent class.

The aggregation relationship

Aggregation relationships in UML are represented by straight lines with hollow diamonds and arrows, a weak dependency that allows parts to stand alone when the whole does not exist.

For example, the validate method in LoginBO uses the findUserByAccAndPwd method in IUserDAO, but when LoginBO is removed, there are other ways to use the IUserDAO method.

Combination relationship

The combinational relation is represented by a straight line with a solid diamond and an arrow, both of which indicate a strong dependence, and where the whole does not exist, there is no need for the parts to exist.

LoginBO is for the LoginForm service. When LoginForm is disabled, LoginBO is no longer necessary.

Realize the relationship between

Used to correlate specification and implementation. It’s represented by a dotted line with a hollow triangle. Our Service layer often uses implementation relationships, where one interface has multiple implementations