What is UML
UML class diagrams provide a quick look at code structure.
2, subject,
Use of UML class diagrams in Pycharm.
3. Preparation
Pycharm version 2.7 or higher
(2) Install the Python interpreter
(3) UML plug-in and UML class diagram plug-in are installed and can be used normally
4. Prepare an example
To create an Animals module and the keepers. Py File (Alt+Insert→Python Package, Python File), type the following code:
Continue to add more classes to it, such as Carnivore and Herbivore.
5. Browse the program structure through UML class diagram
Suppose we want to see the derived structures of Fukubrians, in the Project Tool Window, right click. Py, point to the Diagrams node in the shortcut menu, and select the following available commands:
(1) Show Diagram: Open the UML class Diagram in the current edit TAB
(2) Show Diagram Popup: Show UML class Diagram in a separate window
Select one of these classes (such as Marsupials) and view it using a UML class diagram:
You can also use the shortcut Ctrl+Alt+U (current window) or Ctrl+Alt+Shift+ U (standalone window).
Click the and button for details:
You can also use the shortcut menu:
See the Class Diagram Toolbar and Context Menu page for more Toolbar and Context Menu features.
Next add comments to it. Select the element you want to comment and press Alt+Insert:
Press Enter to enter the comment content:
Click OK to add the comment:
6. Navigation between structure diagram and source code
How do I jump from the structure diagram to the source location of the response?
Select a node element from the structure diagram and press F4 or right-click the shortcut menu and select Jump to Source:
7. Function of UML structure diagram
8. Find all references
Select a node element in the structure diagram, right click, select Find Lead from the shortcut menu, or use Alt+F7 shortcut keys:
9, refactoring
You can refactor (rename, etc.) classes or members directly from the class diagram.
Right-click the node you want to modify in the class diagram, point to the Refactor command, and select the corresponding command from the submenu.
For example, if you want to Rename a class, select it in the class diagram and then select Refactor→Rename shortcut menu command or press Shift+F6:
10. Add elements to the model
Press Space and enter the type and name in the window that pops up:
Add a Carnivore:
Next, manually create more classes, such as Carnivore or Herbivore, and specify the mammal type. For example, Cow inherits from Herbivore and Eutherian. Tiger inherited Carnovire and Eutherian. Duckbill inherited Herbivore and Marsupial, TasmanianDevil inherited Carnivore and Marsupial:
Press Space to add these classes to the class diagram:
Click the button to optimize the display style:
Remove elements from the class diagram
Select an element in the class diagram and Delete:
The deleted class still exists in the source code, but is not visible in the class diagram:
Browse code changes through the class diagram
You are advised to use Ctrl+Alt+Shift+D or a button.
This post is from SDK Community (www.sdk.cn/).