PyCharm Edu 2018.2 Help

Extract Superclass

The Extract Superclass lets you either create a superclass based on an exiting class or you can rename the original class so it becomes an implementation for the newly created superclass. In this case, PyCharm Edu changes all original class usages to use a superclass where possible.

Fields and methods in the original class can be moved to the superclass. Also for a method, you can transfer only the method declaration but not the implementation declaring the method as abstract in the superclass. As a result, you will have the superclass and the original class inherited from the superclass.

Extracting a superclass

To extract a superclass

  1. On the context menu, choose Refactor | Extract | Superclass.

  2. In the Extract Superclass dialog box that appears, specify the following information:
    • Name of the new superclass.

    • Target directory where it will be stored.

    • Methods to be included in the superclass.

    py extract superclass1
  3. Proceed with the refactoring.

py extract superclass2
Last modified: 7 December 2018