Glossary · Automation software engineering and architecture
Inheritance
Also known as: Class inheritance
German: Vererbung
In object-oriented programming, inheritance is a mechanism by which a class or function block (the subclass) is derived from another (the base class), taking over its data and methods and extending or overriding them. IEC 61131-3 supports inheritance for function blocks through the EXTENDS keyword.
- Software engineering
In one sentence
Inheritance derives a class or function block from a base, taking over its data and methods and extending or overriding them.
Example
The function block 'ServoAxis' extends 'BaseAxis', inheriting the common state machine and adding homing and torque limit methods.
How it applies
- Engineering: Inheritance lets common behavior be implemented once in a base class and specialized in derived classes. With interfaces and polymorphism, calling code can work with any derived type through the base type.
- Maintenance: Deep inheritance hierarchies are hard to understand: behavior is spread over several levels, and a change in a base class affects all derived classes. Many designers prefer composition, combining small components, over inheritance.
- Documentation: Library documentation should show the inheritance hierarchy and indicate which members are inherited, overridden or new in each class. Readers otherwise miss inherited behavior when they look at a derived block.
Inheritance vs. SKOS broader/narrower
In software, inheritance is a code reuse and typing mechanism. In a taxonomy or ontology, a narrower concept is a kind of its broader concept, as in RDF (Resource Description Framework) and SKOS models. Both express 'is a kind of', but software inheritance also transfers implementation, which conceptual models do not.