FACTOID # 83: More than half of Indonesia's primary school teachers are under 30years of age .
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "Subtype" also viewed:
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Subtype

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. More specifically, the supertype-subtype relation is often taken to be the one defined by the Liskov substitution principle; however, any given programming language may define its own notion of subtyping, or none at all. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... In computer science, a datatype or data type (often simply a type) is a name or label for a set of values and some operations which one can perform on that set of values. ... Substitutability is a principle in computer programming. ... A computer program is a collection of instructions that describe a task, or set of tasks, to be carried out by a computer. ... In object-oriented programming, the Liskov substitution principle is a particular definition of subtype that was introduced by Barbara Liskov and Jeannette Wing in a 1993 paper entitled Family Values: A Behavioral Notion of Subtyping [1]. (It is not the only definition; see datatype. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...

Contents

Example

Example of Subtypes: Birds
Example of Subtypes: Birds

A simple practical example of subtypes is shown in the diagram, right. The generic object "bird" (or, supertype) gives rise to three derived objects (or, subtypes) "duck", "cuckoo" and "ostrich". Each of these varies the basic "bird" concept in its own way, but still inherits many "bird" characteristics. A data object may be declared as any one of the four types. The UML notation is used in this diagram, with open-headed arrows showing the direction and type of the relationship between the supertype and its subtypes. Image File history File links Inheritance. ... Image File history File links Inheritance. ... In the field of software engineering, the Unified Modeling Language (UML) is a non-proprietary specification language for object modeling. ...


In most class-based object-oriented languages, subclasses give rise to subtypes: if A is a subclass of B, then an instance of class A may be used in any context where an instance of type B is expected; thus we say A is a subtype of B. A consequence of this is that any variable or parameter declared as having type B might, at run time, hold a value of class A; in this situation many object-oriented programmers would say that B is the variable's static type and A is its dynamic type. Exceptions to this rule include private inheritance in C++ (which does not create subtypes), and certain operations on derived types in Eiffel, wherein features inherited from a base class can be removed or modified in a way which violates the subtyping rule. An object-oriented programming language (also called an OO language) is one that allows or encourages, to some degree, object-oriented programming techniques such as encapsulation, inheritance, interfaces, and polymorphism. ... In object-oriented programming, a subclass is a class that inherits some properties from its superclass. ... C++ (IPA pronounciation: ) is a general-purpose, high-level programming language with low-level facilities. ... Eiffel is an object-oriented programming language which emphasizes the production of robust software. ...


As another example, a language might allow integer values to be used wherever floating-point values are expected, or it might define a type number containing both the integers and the reals. In the first instance, the integer type would be a subtype of the floating-point type; in the second, those two types might be unrelated to each other by subtyping but both would be subtypes of number.


Programmers may take advantage of subtyping to write code in a more abstract manner than would be possible without it. Consider the following example:

 function max (x as number, y as number) is if x < y then return y else return x end 

If integer and real are both subtypes of number, then values of either type can be passed to this function. Because of this, subtyping is often considered a form of polymorphism. The above example can also be compared to the template feature of C++. In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ... In computer science, generics is a technique that allows one value to take different datatypes (so-called polymorphism) as long as certain contracts such as subtypes and signature are kept. ...


In type theory, the subtype relation is often written <:, so that A<:B means that A is a subtype of B. Subtyping in type theory is characterized by the fact that any expression of type A may also be given type B if A<:B; the formal typing rule that codifies this is known as the subsumption rule. At the broadest level, type theory is the branch of mathematics and logic that concerns itself with classifying entities into collections called types. ... In logic, especially in mathematical logic, a rule of inference is a scheme for constructing valid inferences. ...


Subtyping schemes

Type theorists make a distinction between nominal subtyping, in which only types declared in a certain way may be subtypes of each other, and structural subtyping, in which the structure of two types determines whether or not one is a subtype of the other. The class-based object-oriented subtyping described above is nominal; a structural subtyping rule for an object-oriented language might say that if objects of type A can handle all of the messages that objects of type B can handle (that is, if they define all the same methods), then A is a subtype of B regardless of whether either inherits from the other. Sound structural subtyping rules for types other than object types are also well known. 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. ... A structual type system is a major class of type system, in which type compatibility and equivalence are determined by the types structure, and not through explicit declarations. ... 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, static methods, or factory methods) or with an object (called instance methods). ... In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined. ...


Implementations of programming languages with subtyping fall into two general classes: inclusive implementations, in which the representation of any value of type A also represents the same value at type B if A<:B, and coercive implementations, in which a value of type A can be automatically converted into one of type B. The subtyping induced by subclassing in an object-oriented language is usually inclusive; subtyping relations that relate integers and floating-point numbers, which are represented differently, are usually coercive.


In almost all type systems that define a subtyping relation, it is reflexive (meaning A<:A for any type A) and transitive (meaning that if A<:B and B<:C then A<:C). This makes it a preorder on types. In mathematics, especially in order theory, preorders are certain kinds of binary relations that are closely related to partially ordered sets. ...


See also

Wikibooks
Wikibooks Ada Programming has a page on the topic of
Subtypes

Image File history File links Wikibooks-logo-en. ... Wikibooks logo Wikibooks, previously called Wikimedia Free Textbook Project and Wikimedia-Textbooks, is a wiki for the creation of books. ... A derived type is a type given a new type but structurally the same as the original type. ... Type has historically had the following uses: In biology, a type is the specimen or specimens upon which an original species description is based. ... A covariant type operator in a type system preserves the ordering of types. ...

External links


  Results from FactBites:
 
Is HIV one or many viruses? (938 words)
For instance, subtype B is mostly found in the Americas, Japan, Australia, the Caribbean and Europe; subtypes A and D predominate in sub-Saharan Africa; subtype C in South Africa and India; and subtype E in Central African Republic, Thailand and other countries of southeast Asia.
It has also been suggested that certain subtypes may be predominantly associated with specific modes of transmission: for example, subtype B with homosexual contact and intravenous drug use (essentially via blood) and subtypes E and C, with heterosexual transmission (via a mucosal route).
It is not known whether the genetic variations in subtype E or other subtypes actually make a difference in terms of the risk of transmission, the response to antiviral therapy, or prevention by vaccine.
HIV types, subtypes, groups & strains (2240 words)
These are subtypes A, B, C, D, F, G, H, J and K. Occasionally, two viruses of different subtypes can meet in the cell of an infected person and mix together their genetic material to create a new hybrid virus (a process similar to sexual reproduction, and sometimes called "viral sex").
Subtype C is predominant in Southern and East Africa, India and Nepal.
The development of an AIDS vaccine is affected by the range of virus subtypes as well as by the wide variety of human populations who need protection and who differ, for example, in their genetic make-up and their routes of exposure to HIV.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.