Abstract type

In programming languages, an abstract type (also known as existential types)[1] is a type in a nominative type system that cannot be instantiated directly; by contrast, a concrete type can be instantiated directly. Instantiation of an abstract type can occur only indirectly, via a concrete subtype.

An abstract type may provide no implementation, or an incomplete implementation. In some languages, abstract types with no implementation (rather than an incomplete implementation) are known as protocols, interfaces, signatures, or class types. In class-based object-oriented programming, abstract types are implemented as abstract classes (also known as abstract base classes), and concrete types as concrete classes. In generic programming, the analogous notion is a concept, which similarly specifies syntax and semantics, but does not require a subtype relationship: two unrelated types may satisfy the same concept.

Often, abstract types will have one or more implementations provided separately, for example, in the form of concrete subtypes that can be instantiated. In object-oriented programming, an abstract class may include abstract methods or abstract properties[2] that are shared by its subclasses. Other names for language features that are (or may be) used to implement abstract types include traits, mixins, flavors, roles, or type classes.[citation needed]

Abstract types may also include any number of non-abstract methods and properties, such as when implementing the Template Method Pattern which uses a mixture of invariant methods with fixed implementations and hook methods which can be overridden in concrete subclasses to provide custonised logic.

  1. ^ Mitchell, John C.; Plotkin, Gordon D.; Abstract Types Have Existential Type, ACM Transactions on Programming Languages and Systems, Vol. 10, No. 3, July 1988, pp. 470–502
  2. ^ "Abstract Methods and Classes (The Java Tutorials > Learning the Java Language > Interfaces and Inheritance)". Oracle.com. Retrieved 2019-08-14.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search