[WEBINAR] The New Normal: Dealing with the Reality of an Unsecure World


Definition - What does Subtyping mean?

Subtyping is a notion in programming language theory where a subtype, which is a data type, is related to a supertype based on the notion of substitutability, where program elements such as functions and subroutines that are written for the supertype will still operate if given the subtype instead. Subtypes are an essential concept in object-oriented programming and are substitutable to supertypes and sometimes even have more stringent specifications than the supertype.

Techopedia explains Subtyping

Subtyping is a method for substitution and code reuse used in object-oriented programming languages to prevent unnecessary copying of largely similar code and promote code readability and prevent bugs. A subtype is basically a substitute for a supertype that can fulfill all of the latter's specifications, and then some. So if B is a subtype of A, then B can always be used to substitute for an A and any property that is guaranteed by A must also be guaranteed by B.

The subtype is allowed to strengthen and even add properties that are not on the supertype, which means that it allows the supertype to be extended. So, instead of creating a new supertype every time something new is required and then copying properties and conditions from another supertype, a subtype could simply be created that extends the supertype with additional properties or features without changing the supertype. Then, in this case, everything that is provable to the supertype will also be provable to the subtype and more. If a subtype is treated purely the same way as the supertype by using and querying only supertype methods and fields, then the results would be consistent with objects of the supertype.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.