preface

I believe many developers are familiar with UML diagrams.

Why suddenly write such a far-fetched content? In the course of writing the RocketMQ source code parsing series, He found that he needed some diagrams to better represent the structure and call relationships in the source code.

We probably see the most use-case diagrams and class diagrams. Based on the purpose of in-depth study and comprehensive development, Feihao briefly combed 9 kinds of common UML diagrams at ordinary times.

The body of the

The nine common UML diagrams are:

  • Use case diagram
  • The class diagram
  • Object graph
  • The sequence diagram
  • Collaboration diagrams
  • State diagram
  • Activity diagrams
  • Component diagram
  • Deployment diagram

Use case diagram

Describes the functions of the system from the user’s point of view, and describes the relationship between the user and the system use cases. Simply put, it’s what users can do with the system!

Relationships involved in use case diagrams:

Reference Examples:

The class diagram

According to the use case diagram, the user abstracts the class into a static structure diagram, which describes the internal structure of the class and the relationship between the attributes of the class and the class.

In UML class diagrams, the following relationships are common:

  • Generalization.
  • Realization
  • Association
  • Aggregation
  • Composition
  • Dependency

The order of strength and weakness of various relationships: Generalization = implementation > Composition > Aggregation > Association > dependency

generalization

Is an inheritance relationship, indicating that a subclass inherits all the characteristics and behaviors of its parent class.

implementation

Is a class to interface relationship, indicating that the class is the implementation of all the characteristics and behavior of the interface.

associated

Is an ownership relationship that allows one class to know the properties and methods of another class.

For example: the teacher and the student are two-way correlation, the teacher has more than one student, students can also correspond to more than one teacher; But a student can only be associated with more than one course

A two-way association can have two arrows or no arrows, and a one-way association has one arrow

The aggregation

It’s a whole and parts relationship. And parts can exist independently of the whole. Aggregation relation is a kind of correlation relation, which is strong correlation relation. Association and aggregation are syntactically indistinguishable and must be examined for specific logical relationships.

If the car and tire are whole and part of the relationship, the tire can still exist without the car.

combination

It’s a whole and parts relationship. However, the part cannot exist independently without the whole, and the combinatorial relation is a kind of correlation relation, which is stronger than the aggregation relation.

If companies and departments are integral and partial, there would be no departments without companies.

It requires that objects representing the whole in a normal aggregation relationship be responsible for the life cycle of objects representing the parts.

Rely on

Is a usage relationship in which the implementation of one class requires the assistance of another class.

Briefly summarize the above relations and corresponding symbols:

Object graph

Describes the state of each object participating in an interaction at a certain point in the interaction. An object diagram can be thought of as an instance of a class diagram at one point in time.

For example, there can only be one person Edison in the R&D department and sales department of BAT Company at a certain time

State diagram

Is a state machine composed of states, transitions, events, and activities, used to describe all possible states of objects of a class and state transition conditions when time occurs.

A state machine consists of five parts: states, transitions, events, activities and actions

  • state
  • conversion
  • The event
  • activity
  • action

Activity diagrams

Is a special case of state diagrams, most of which are active. Essentially a flow chart that describes the flow of control from activity to activity.

Interaction diagrams emphasize the flow of control from object to object, whereas activity diagrams emphasize the flow of control from activity to activity.

Activity diagrams are a technique for expressing process fundamentals, business processes, and workflows. It can be used to model business processes, workflows, use-case realizations, and even program realizations.

Activity diagram elements: action and activity nodes, start and stop, control flow, judgment nodes, merge nodes, swimlanes.

Go straight to the example:

The sequence diagram

Also known as a sequence diagram, it describes the order in which messages are sent between objects, with an emphasis on time order. This is also a kind of fat hao usually draw more, because it is not only simple painting, but also intuitive expression.

I don’t want to go into details here, but just put a sequence diagram of Dubbo’s exposure service:

Collaboration diagrams

A type of interaction diagram that describes the organizational relationships of objects receiving and receiving messages, emphasizing the cooperative relationships between objects. Sequence diagrams are laid out in chronological order, while collaboration diagrams are laid out in spatial structure

Component diagram

Component diagram is used to represent the relationship between components, classes or interfaces and components in the system. Among them, the relationship between build diagrams is represented as dependency relationship, and the relationship between defined classes or interfaces and classes is represented as dependency relationship or implementation relationship.

Things in a component diagram

Relationships in component diagrams

Deployment diagram

Describes the configuration of nodes that the system processes and the components that move on the nodes. Physical devices and their connections are emphasized.

The purpose of deploying the model:

Describe the main deployment structure of a specific application. Through the display of various hardware, software in the hardware and various connection protocols, you can describe how the system is deployed. Balance the distribution of computing resources during system operation; It can describe the hardware network structure of the organization or embedded system with various hardware and software related system operation models.

Source: www.processon.com/view/5ee37b…

summary

Common UML diagram is probably a brief overview of the time, fat in the commonly used words may be the use case diagram, class diagram, sequence diagram these several bar. Others are used less and not much detailed introduction and notes, if used in the future can be supplemented. The purpose of this note is mainly in order to better write RocketMQ source series chapter, of course, if you can be familiar with various UML diagrams, for personal also have a certain help and growth.

Ordinary change, will change ordinary

I am fat hao, a low-key young man in the Internet

Please visit my blog at 📖 edisonz.cn for more shared articles