SUPPORT THE WORK

GetWiki

Abstract type

ARTICLE SUBJECTS
aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
ARTICLE TYPES
essay  →
feed  →
help  →
system  →
wiki  →
ARTICLE ORIGINS
critical  →
discussion  →
forked  →
imported  →
original  →
Abstract type
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{distinguish|Abstract data type}}In programming languages, an abstract type is a type in a nominative type system that cannot be instantiated directly; a type that is not abstract – which can be instantiated – is called a concrete type. Every instance of an abstract type is an instance of some concrete subtype. Abstract types are also known as existential types.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–502An 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 propertiesweblink 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|date=September 2014}}

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, D or C.
  • By including, in the class definition, one or more abstract methods (called pure virtual functions in C++), 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 that sends a particular method to this, but doesn't implement that method, can be considered abstract. (However, in many such languages, like Objective-C, the error is not detected until the class is used, and the message returns results in an exception error message such as "Does not recognize selector: xxx" as - [NSObject doesNotRecognizeSelector:(SEL)selector] is invoked upon detection of an unimplemented method).

Example (Java)

//By default, all methods in all classes are concrete, unless the abstract keyword is used.abstract class Demo {
// An abstract class may include abstract methods, which have no implementation.
abstract public int sum(int x, int y);


// An abstract class may also include concrete methods.
public int product(int x, int y) { return x*y; }
}//By default, all methods in all interfaces are abstract, unless the default keyword is used.interface DemoInterface {
[abstract] int getLength(); //Abstract can be used here, though is completely useless

//The default keyword can be used in this context to specify a concrete method in an interface
default int product(int x, int y) {
return x * y;
}
}

Use of abstract types

Abstract types are an important feature in statically typed OOP languages. 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.Some authors argue that classes should be leaf classes (have no subtypes), or else be abstract.BOOK, Riel, Arthur, Object-Oriented Design Heuristics, Addison-Wesley Professional, 1996, 0-201-63385-X, 89, BOOK, Meyers, Scott, More Effective C++, Addison-Wesley Professional, 1996, 0-201-63371-X, 258, Make non-leaf classes abstract, Abstract types are useful in that they can be used to define and enforce a protocol; a set of operations that all objects implementing the protocol must support.

See also

References

{{Reflist}}

Further reading

  • BOOK, Head First Java, 2003, O'Reilly Media, 0-596-00920-8, 688,weblink
  • Core Java: An Integrated Approach by R. Nageswara Rao

External links



- content above as imported from Wikipedia
- "Abstract type" does not exist on GetWiki (yet)
- time: 11:45pm EDT - Sat, May 25 2019
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 09 MAY 2016
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
GETWIKI 20 AUG 2014
GETWIKI 19 AUG 2014
GETWIKI 18 AUG 2014
Wikinfo
Culture
CONNECT