|
In software engineering, an abstract type is a type in a nominative type system which is declared by the programmer, and which has the property that it contains no members which are also not members of some declared subtype. In many object oriented programming languages, abstract types are known as abstract base classes, interfaces, traits, mixins, flavors, or roles. Note that these names refer to different language constructs which are (or may be) used to implement abstract types. Software engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software. ...
A nominative type system is a major classes of type system, in which type compatibility and equivalence is determined by explicit declarations and/or the name of the types. ...
In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ...
In computer science, object-oriented programming, OOP for short, is a computer programming paradigm. ...
Traits is an abstract type, used as a simple conceptual model for structuring object oriented programs. ...
In object-oriented programming languages, a mixin is an approach to implementing classes that differs from the most widely-used approach coming from the programming language Simula. ...
Signifying abstract types
Abstract classes can be created, signified, or simulated in several ways: - By use of the explicit keyword abstract in the class definition, as in Java.
- By including, in the class definition, one or more methods (called pure virtual functions in C++); methods which the class is declared to accept as part of its protocol, but for which no implementation is provided.
- By inheriting from an abstract type, and not overriding all missing features necessary to complete the class definition.
- In many dynamically typed languages such as Smalltalk, any class which sends a particular method to this, but doesn't implement that method, can be considered abstract. (However, in many such languages, the error is not detected until the class is used, and the message send results in an error such as doesNotUnderstand).
In computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. ...
Used mainly in object-oriented programming, the term method refers to a piece of code that is exclusively associated either with a class (called class methods or static methods) or with an object (called instance methods). ...
This article or section should be merged with Virtual method In many object oriented programming languages such as C++, C#, VB.NET, a virtual function is a function that can be overridden with specialized implementations in subclasses. ...
C++ (pronounced see plus plus, IPA: ) is a general-purpose programming language with high-level and low-level capabilities. ...
This article or section does not cite any references or sources. ...
For other uses, see Small talk. ...
In many object-oriented programming languages, this (or self) is a keyword which is used to refer to the object on which the currently executing method has been invoked. ...
Use of abstract types Abstract types are an important feature in statically typed OO languages. They do not occur in languages without subtyping. Many dynamically typed languages have no equivalent feature (although the use of duck typing makes abstract types unnecessary); however traits are found in some modern dynamically-typed languages. On computer science, a datatype (often simply type) is a name or label for a set of values and some operations which can be performed on that set of values. ...
In computer science, a type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. ...
Duck typing is a style of dynamic typing in which an objects current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class. ...
Many authors argue that classes should be leaf classes (have no subtypes), or else be abstract. In class-based object-oriented programming languages, a leaf class is a class that should not be subclassed. ...
Abstract types are useful in that they can be used to define and enforce a protocol; a set of operations which all objects that implement the protocol must support. The fact that many languages disallow instantiation of abstract types (and force subtypes to implement all needed functionality) further ensures program correctness. In computer sciences object-oriented programming, a protocol (Java: interface) is what or how unrelated objects use to communicate with each other. ...
Instantiation is the process of creating a specific object (computing) which is a member or instance of a class (computing). ...
In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification. ...
Types of abstract types There are several mechanisms for creating abstract types, which vary based on their capability. - Full abstract base classes are classes either explicitly declared to be abstract, or which contain abstract (unimplemented) methods. Except the instantiation capability, they have the same capabilities as a concrete class or type. Full abstract types were present in the earliest versions of C++; and the abstract base class remains the only language construct for generating abstract types in C++. A class having only pure virtual methods is often called a pure virtual class; it is necessarily abstract.
- Note: Due to technical issues with multiple inheritance in C++ and other languages; many OO languages sought to restrict inheritance to a single direct base class. In order to support multiple subtyping, several languages added other features which can be used to create abstract types, but with less power than full-blown classes
- Common Lisp Object System includes mixins, based on the Flavors system developed by David Moon for Lisp Machine Lisp. (It should be noted that CLOS uses generic functions, defined apart from classes, rather than member functions defined within the class).
- Java includes interfaces, an abstract type which may contain method signatures and constants (final variables), but no method implementations or non-final data members. Java classes may "implement" multiple interfaces. An abstract class in Java may implement interfaces and define some method signatures while keeping other methods abstract with the "abstract" keyword.
- Traits are a more recent approach to the problem, found in Scala and Perl 6 (there known as roles), and proposed as an extension to Smalltalk (wherein the original implementation was developed). Traits are unrestricted in what they include in their definition, and multiple traits may be composed into a class definition. However, the composition rules for traits differ from standard inheritance, to avoid the semantic difficulties often associated with multiple inheritance.
C++ (pronounced see plus plus, IPA: ) is a general-purpose programming language with high-level and low-level capabilities. ...
Multiple inheritance refers to a feature of object-oriented programming languages in which a class can inherit behaviors and features from more than one superclass. ...
In computer science, a subtype states that if given type A is compatible with type B, then A is a subtype of B while not always vice versa. ...
The Common Lisp Object System (CLOS) is the facility for object-oriented programming which is part of Common Lisp (CL). ...
In object-oriented programming languages, a mixin is an approach to implementing classes that differs from the most widely-used approach coming from the programming language Simula. ...
Flavors, an early object-oriented extension to Lisp developed by Howard Cannon at the MIT Artificial Intelligence Laboratory for the Lisp machine, was the first programming language to include mixins. ...
David A. Moon is a programmer and computer scientist, well known for his work on the Lisp programming language and related topics. ...
Lisp Machine Lisp is a dialect of the Lisp programming language, a direct descendant of MacLisp, and was initially developed in the mid to late 1970s as the systems programming language for the MIT Lisp machines. ...
In certain systems for object-oriented programming such as the Common Lisp Object System and Dylan, a generic function is an entity made up of all methods having the same name. ...
Used mainly in object-oriented programming, the term method refers to a piece of code that is exclusively associated either with a class (called class methods or static methods) or with an object (called instance methods). ...
âJava languageâ redirects here. ...
An interface in the Java programming language is an abstract type which is used to specify an interface (in the generic sense of the term) that classes must implement. ...
Traits is an abstract type, used as a simple conceptual model for structuring object oriented programs. ...
ALA Logo The American Library Association (ALA) is a group based in the United States that promotes libraries and library education internationally. ...
Perl 6 is a planned major revision to the Perl programming language. ...
For other uses, see Small talk. ...
External links - Types and Programming Languages by Benjamin Pierce (MIT Press 2002) [1]
- More Effective C++: 35 New Ways to Improve Your Programs and Designs by Scott Meyers (1995) ISBN 0-201-63371-X
- Traits: Composable Units of Behavior by Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz and Andrew Black
|