Subtyping and Inheritance

Learn about subtyping and inheritance.

Subtyping and inheritance in computational languages

Subtyping and inheritance are supported in Object-Oriented Programming (OOP), database languages (such as SQL99), XML schema definition language, and other computational languages in various ways and to different degrees. At its core, subtyping in computational languages is about defining type hierarchies and the inheritance of features. These include properties, constraints, and methods in OOP; table columns and constraints in SQL99; elements, attributes, and constraints in XML Schema.

Generally, it’s helpful to have support for multiple classification and multiple inheritance in type hierarchies. Both language features are closely related and are considered to be advanced features. They might not be needed in many applications. They can alos be dealt with by using workarounds.

Multiple classification means that an object has more than one direct type. This is mainly the case when an object plays multiple roles at the same time and therefore directly instantiates multiple classes that define these roles.

Multiple inheritance is typically also related to role classes. For instance, a student assistant is a person that plays both the role of a student and an academic staff member,. As a result, the corresponding OOP class StudentAssistant inherits from both role classes Student and AcademicStaffMember.

Get hands-on with 1200+ tech skills courses.