When we usually look at the code, we often encounter some methods with more complicated processes. At this time, drawing a sequence diagram will help us understand the execution process of the method. However, the execution process of these methods is often long, and the hand-drawn sequence diagram is too troublesome! Today, I recommend an IDEA plug-in to you, which can generate sequence diagrams directly according to the method, which greatly improves efficiency!
SpringBoot actual e-commerce project mall (50k+star) address: https://github.com/macrozheng/mall
Introduction to SequenceDiagram
SequenceDiagram is a plug-in that can generate sequence diagrams based on code. Its functions are very powerful. The main features are as follows:
- Can generate timing diagram directly from code;
- You can navigate directly to the corresponding code from the sequence diagram;
- Classes and methods can be edited directly on the sequence diagram;
- Timing diagrams can be exported as images or PlantUML files.
use
Let's talk about the use of the SequenceDiagram
plug-in, which is used to draw a login flowchart of the mall project.
- First of all, we need to install the
SequenceDiagram
plug-in in IDEA's plug-in market;
- Then find a method to try, here is the login method in my mall project as an example, right-click method to select generate sequence diagram;
- At this point, you can see the generated sequence diagram in the sequence diagram panel at the bottom. Here is a brief introduction to the usage of the buttons on the left;
- Click the Settings button, we can set the generation level, only display the classes in the project, skip the Getter/Setter and skip the constructor;
- In the sequence diagram, we can choose a class or method and jump directly to the source code;
- Some classes and methods of the directly generated sequence diagram are redundant, we can use the operation of deleting nodes to edit;
- After some simplification, a sequence diagram with a clear process is made. Isn't it very simple!
- We can export as pictures, currently only support
svg
format;
- It can also be exported as a PlantUML file. I introduced a very useful PlantUML plug-in before, and you can use it to preview and edit the PlantUML file;
- After the installation is successful, open the PlantUML file for preview, the effect is quite good;
- The automatically generated annotations are all method names. If we want to change them into meaningful Chinese annotations, we can use the PlantUML plug-in to modify them. The effect after modification is as follows.
Summarize
Drawing a sequence diagram does help us understand the execution flow of complex methods, but hand-drawing is too cumbersome. We can generate the initial sequence diagram through SequenceDiagram
, then remove some useless classes and methods, and then modify it through the PlantUML plugin, so that we can quickly get a satisfactory sequence diagram, everyone is interested Give it a try!
References
Official website: https://github.com/Vanco/SequencePlugin
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。