Polymorphism can be described easily by
Liskov Substitution Principle: "Derived class object can be used where base class object is expected."
This way, programs dont need to rely on low level details of object implementations. This reduces considerably dependencies between modules. Less dependencies means more maintainable and easier to modify programs.
Polymorphism is essential to Object Oriented Programming.

Also a biological word used to describe a gene that, through mutation and natural selection, has three possible alleles instead of the regular two. Polymorphism of a gene tends to cause a greater diversity within the species. For example, human blood type is polymorphic. We each have two of three alleles (either A, B, or o) in different combinations.

In Object Oriented Programming, polymorphism (properly: parametric polymorphism) enables us to process objects differently based on their type. It is usually accomplished by allowing derived classes to redefine methods of a base class in order to replace or extend the behaviour of those methods.

The classic example is a base class called Shape and a set of derived classes such as Circle and Triangle. The base class implements an abstract draw method, and the derived objects override it with their own drawing code. Except for the object type, the method signatures are the same.

polymorphism: the quality or character of occurring in several different forms.

Dictionary of Sexology Project: Main Index

One facet of polymorphism (wrt the Lambda Calculus) is the study of functions that take polymorphic arguments i.e., the action in the body of the function does not depend on the type of the arguments.

First, some notation. We denote a function that takes some argument x of type t and returns e of type s as \x:t.e:s. We say this function has type t->s. To apply a function to an argument, we just use juxtaposition: (\x:t.e:s) v. Note that v:t and the whole expression has type s.

So what functions are of type t->t? Since we know nothing about the type t, the only thing we can return is the argument itself: \x:t.x:t. This is not very interesting.

What about functions of type t->t->t? Basically, we take two arguments (this is a curried function), and since we know nothing about the type (i.e., we can't add the arguments or whatever), all we can do is return the first argument (T = \x:t.\y:t.x) or the second (F = \x:t.\y:t.y). So what type is this really (t->t->t)? Well, it's bool, the type with only two elements. Note that I called these elements T and F.

Now let's have some fun with this new way of looking at bool. We can make an if-then-else statement simply by function application: b e1 e2 evaluates to e1 if b = T and to e2 if b = F. Thus e1 is the then clause and e2 is the else clause. We can construct the function NOT = \b:bool.b F T and AND = \x:bool.\y:bool. x y F.

What about functions of type t->(t->t)->t? Consider \z:t.\s:t->t.e:t. Well, we take as arguments z:t and a function s:t->t. Since we need to return something of type t, we can just return z. Or we can return s z, or s (s z) or s (s (s z)), etc. So what type is this? You guessed it, it's nat, the natural numbers (z is zero, and s is the successor function. We can have a lot of fun with this one, but that is beyond the scope of this writeup. Take a course in lambda calculus or type theory if you want more.

Does your head hurt yet?

About the easiest way to remember what Polymorphism is without running into more techinal jargon is to think of it as the following:

Polymorphism is about making things more the same than different.

For a simple analogy, say you're going to produce two kinds of bags, and these bags will be used to hold either apples or banannas. Rather than creating two entirely separate production lines to create the bags for the two different kinds of fruits, it makes a lot more sense to use the same production line to make both kinds of bags (since they shouldn't be very different, if at all).

In Object Oriented Programming, you're making modules (classes) rather than bags, and they're being used to hold and manage slightly different kinds of data.

Difference in DNA sequences among individuals. Genetic variations occurring in more than 1% of a population would be considered useful polymorphisms for genetic linkage analysis. Compare mutation.

From the BioTech Dictionary at http://biotech.icmb.utexas.edu/. For further information see the BioTech homenode.

Pol`y*mor"phism (?), n.

1. Crystallog.

Same as Pleomorphism.

2. Biol. (a)

The capability of assuming different forms; the capability of widely varying in form.


Existence in many forms; the coexistence, in the same locality, of two or more distinct forms independent of sex, not connected by intermediate gradations, but produced from common parents.


© Webster 1913.

Log in or register to write something here or to contact authors.