The most complete Pycharm tutorial (43) -- Use of UML class diagrams for Pycharm extension Functions

Source: Internet
Author: User

The most complete Pycharm tutorial (43) -- Use of UML class diagrams for Pycharm extension Functions

1. What is UML?

The UML class diagram can quickly check the code structure.

2. Subject

Usage of UML class diagrams in Pycharm.

3. Preparations

(1) The Pycharm version is 2.7 or higher.

(2) install the Python Interpreter

(3) install and use the UML plug-ins and UML class diagrams.

4. Prepare an example

CreateAnimalsModule and the Mammal. py File (Alt + Insert → Python Package, Python File), enter the following code:

Add more categories to the cluster, for exampleCarnivoreAndHerbivore.

5. Browse program structure through UML class diagram

Suppose we want to view the derived structure of mammals. In the Project tool window, right-clickMammal. py, PointingDiagramsNode, select the following available commands:

(1) Show digraphs: Open the UML class Diagram on the current editing tab.

(2) Show dimo-popup: displays the UML class Diagram in a separate window.

Select a class (such as marsupials) in mammals and view it using the UML class diagram:

You can also use the shortcut key Ctrl + Alt + U (current window) or Ctrl + Alt + Shift + U (independent window ).

Click and click to View Details:

You can also use the shortcut menu:

For more information about the Toolbar and shortcut Menu, see the Class dimo-toolbar and Context Menu page.

Next, add a comment to it. Select the element to be annotated, and press Alt + Insert:

Press enter and enter the comment:

Click OK to add the comment:

6. navigation between structure chart and source code

How can I jump from the structure chart to the source code of the response?

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

7. Functions of UML Structure Diagram

8. Search for all references

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

9. Reconstruction

You can directly refactor the class or member in the class diagram (rename or so on ).

In the class diagram, right-click the node to be modified, point to the Refactor command, and select the corresponding command from the sub-menu.

For example, if you want to Rename a class, you need to select it in the class diagram, 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 pop-up window:

AddCarnivore:

Next, create more categories manually, as shown in figureCarnivoreOrHerbivore,Specifies the mammal type. For exampleCowInheritedHerbivoreAndEutherian.TigerInheritedCarnovireAndEutherian.DuckbillInheritedHerbivoreAndMarsupial,TasmaniandedevilInheritedCarnivoreAndMarsupial:

Press Space to add these classes to the class diagram:

Click the button to optimize the display style:

11. Remove elements from the class diagram

Select an element in the class diagram, Delete:

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

12. Browse code changes through class diagrams

We recommend that you use the Ctrl + Alt + Shift + D shortcut or button.

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.