UML | Detailed UML Class Diagram

Basic introduction to UML

UML (Unified Modeling Language) is a language tool for software system analysis and design. It is used to help software developers think and record the results of their ideas.
UML itself is a set of symbolic regulations, just like mathematical symbols and chemical symbols. These symbols are used to describe the various elements in the software model and their relationships, such as classes, interfaces, implementations, generalizations, dependencies, combinations, Aggregation etc.

UML class diagram

  • Used to describe the composition of the class (object) itself and various static relationships between the class (object) in the system
  • The relationship between classes: dependency, generalization (inheritance), realization, association, aggregation and composition

Let's explain the six relationships:

Dependency

As long as the other party is used in the class, there will be a dependency relationship between them. If there is no other party, even the compilation will not pass. The following are all dependencies:

  • Each other is used in the class
  • Class member properties
  • Method return type
  • Types of parameters received by the method
  • Used in the method

Generalization relationship

The generalization relationship is actually the inheritance relationship , which is a special case of the dependency relationship.

Realization relationship

The realization relationship is actually the realization of class A and class B, which is a special case of dependency

connection relation

Association relationship is actually the connection between class and class, it is a special case of dependency .
Associations are navigational : that is, a two-way relationship or a one-way relationship.
The relationship has multiple characteristics: such as "1" (representing one and only one), "0..." (representing 0 or more), "0,1" (representing 0 or one), "n.. .m" (means n to m can be), "m..." (means at least m).

Aggregation relationship

The aggregation relationship represents the relationship between the whole and the part. The whole and the part can be separated. The aggregation relationship is a special case of the association relationship , so it has the navigation and multiplicity of association.
For example, a computer is composed of a monitor, a mouse, etc. The various accessories that make up the computer can be separated from the computer, and are represented by the realization with a hollow diamond.

Combination relationship

The combination relationship is also the relationship between the whole and the part, but the whole and the part cannot be separated .
For example: in the program we define entities, Person (person) and IDCard (identity card), Head (head), then Head (head) and Person (person) is a combination, IDCard and Person are aggregation.

public class Person{
    private IDCard card;
    private Head head = new Head();
}
class IDCard{
}
class Head{
}

However, if the cascading deletion of IDCard is defined in the Person entity in the program , that is, when the Person is deleted, the Unicom IDCard is deleted together, then IDCard and Person are combined.

Guess you like

Origin blog.csdn.net/qq_14810195/article/details/106599113