Inheritance principle

Content of the inheritance

A derived function block inherits all data, methods, properties, actions and transitions, which are defined in the basic function block. Note the access options to inherited elements, which are defined via access modifiers.

Access options to inherited elements

To what extent a subclass can access inherited methods or properties within its scope depends on the access modifier, with which the method or property is defined in the base class.

Methods and properties, which are defined in the base class with the access modifier PRIVATE, cannot be called within the scope of the subclass, nor can they be overwritten or extended by the subclass.
Private methods and properties are available for the subclass only in so far as that they are executed for the instance of the subclass, if they are called within the implementation of the base class.

Example:

The base class has a PUBLIC and a PRIVATE method. The PUBLIC method calls the PRIVATE method in its implementation. The PUBLIC method can be called by the subclass called, so that the PRIVATE method is called implicitly at the same time. However, the PRIVATE method cannot be actively called, overwritten or extended by the subclass.

The following access modifiers available for specifying access options to a method or property:

PUBLIC

Corresponds to the specification of no access modifier. The element (method or property) can be called from outside the function block. Therefore, the element can also be accessed by a subclass.

PRIVATE

Access to the element is limited to the function block. Access from outside the function block is not possible. This means that a subclass cannot access the element either. The subclass can therefore neither call the element, nor overwrite or extend it.

PROTECTED

Access to the element is limited to the function block and its derivatives. A subclass can access the element and can therefore call, extend or overwrite it. Access from outside this "inheritance family" is not possible.

INTERNAL

Access to the element is limited to the namespace (the library). Access from outside the namespace is not possible. Therefore, the element cannot be overwritten or extended from outside the namespace.

Extending or overwriting of inherited elements

Engineering tip: The following engineering support is provided for extending or overwriting methods, properties, actions and transitions inherited by the function block: When you add a method, property etc. to the derived function block, the Name of the Add dialog (e.g. Add Method, Add Property) offers a drop-down list with a choice of methods, properties etc. used in the basic function block. If, for example, you select one of these methods in the Add Method dialog, the other declaration settings for the method (return type, access modifier) are automatically applied to the method declaration of the base class. When you confirm the dialog, the method is created according to these declarations. You can customize the implementation part of the method such that it matches the desired behavior of the subclass.

Further information on extending and overwriting can be found in section “Use cases for inherited elements”.

Further considerations relating to extensions