How to override operations form superclass

Method overriding is a very common technique in object-oriented programming. It allows developer deliver specific implementation of a method in the subclass although it already defined by the superclass. When overriding a method the subclass replace the implementation in superclass by providing a method which exactly same as the one in superclass, i.e same name, parameter and also the return type. In Visual Paradigm you don’t need to redefine the operation in subclass to model the override. You can simply do it in one click inside the specification dialog. To override the operation:

  1. Right click on the subclass and select Open Specification from the popup menu.

    Open specification dialog for subclass

    Open specification dialog for subclass

  2. Switch to Operations tab and select the operation from superclass (indicated in Classifier column) which you wish to override.

    Select the operation to overrode

    Select the operation to overrode

  3. Press the Override button and you will see the Classifier of the operation changed form superclass to subclass.

    The method is being overridden

    The method is being overridden

  4. Now the method is being overridden and show in the subclass.

    Overridden method showing in subclass

    Overridden method showing in subclass

  5. When perform code generation the method will also being generated into the subclass and waiting for you to fill in the custom implementations.

    Source code of subclass showing overridden method

    Source code of subclass showing overridden method

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply