The most complete pycharm tutorial (--pycharm) The UML class diagram with extended function

Source: Internet
Author: User

1, what is UML

UML class diagrams can quickly examine code structures.

2. Theme

The use of UML class diagrams in Pycharm.

3. Preparation work

(1) Pycharm version is 2.7 or higher

(2) Installing the Python Interpreter

(3) UML Plug-ins and UML class diagram plug-in installation and normal use

4. Prepare an example

Create a Animals module and mammal.py file (Alt+insert→python Package, Python file) and enter the following code:

Continue to add more classes to them, such as carnivore and herbivore.

5, through the UML class diagram browsing program structure

Suppose we want to see the mammals's derived structure, in the Project tool window, right-click mammal.py, point to the diagrams node on the shortcut menu, and select the following available commands:

(1) Show Diagram: Open UML Class diagram in the current editing tab

(2) Show Diagram Popup: Display UML class diagrams in a separate window

Select a class in mammals (for example, marsupials) and view it with a UML class diagram:

You can also use the shortcut key Ctrl+alt+u (current window) or ctrl+alt+shift+ U (standalone window).

Click and button to view more information:

You can also use the shortcut menu:

More toolbars and shortcut menu features see class Diagram Toolbar and Context menu pages.

Next, add a comment to it. Select the element you want to annotate and press Alt+insert:

Enter the comment content:

Click OK, add complete comments:

6. Navigation between the structure diagram and the source code

How to jump from the chart to the source location of the response.

Select a node element in the structure diagram, press F4 or right-click the shortcut menu to select Jump to Source command:

7, UML structure diagram function

8. Find All References

Select a node element in the chart, right-click, select Find Usages from the shortcut menu, or use the Alt+f7 shortcut key:

9, refactoring

You can refactor a class or member directly in a class diagram (rename, and so on).

Right-click the node you want to modify in the class diagram, point to the Refactor command, and select the corresponding command in the submenu.

For example, if you want to rename a class, you need to select it in the class diagram, select the Refactor→rename shortcut menu command, or press SHIFT+F6:

10. Adding elements to the model

Press space to enter the type and name in the pop-up window:

Add Carnivore:

Next, manually create more classes, such as carnivore or herbivore, to specify the mammal type. For example, Cow inherited herbivore and EutherianTiger inherited carnovire and EutherianDuckbill 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:

11. Removing elements from class diagrams

Select an element in the class diagram, Delete:

The deleted class still exists in the source code, but is not visible in the class diagram:

12. Browse code changes by class diagram

It is recommended to use Ctrl+alt+shift+d shortcuts, or buttons.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.