Tags:
create new tag
, view all tags
It's about time I dug into polymorphism — I'll start with some dictionary definitions.

See:

Contents

Dictionary Definitions

from the hyperdictionary:

WordNet Dictionary

[n] (biology) the existence of two or more forms of individuals within the same animal species (independent of sex differences)

[n] (chemistry) the existence of different kinds of crystal of the same chemical compound

Webster's 1913 Dictionary

2. (Biol.) (a) The capability of assuming different forms; the capability of widely varying in form. (b) 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.

Computing Dictionary

Definition: A concept first identified by Christopher Strachey (1967) and developed by Hindley and Milner, allowing types such as list of anything. E.g. in Haskell:

length :: [a] -> Int is a function which operates on a list of objects of any type, a (a is a type variable). This is known as parametric polymorphism. Polymorphic typing allows strong type checking as well as generic functions. ML in 1976 was the first language with polymorphic typing.

Ad-hoc polymorphism (better described as overloading) is the ability to use the same syntax for objects of different types, e.g. "+" for addition of reals and integers or "-" for unary negation or diadic subtraction. Parametric polymorphism allows the same object code for a function to handle arguments of many types but overloading only reuses syntax and requires different code to handle different types.

See also generic type variable.

In object-oriented programming, the term is used to describe a variable that may refer to objects whose class is not known at compile time and which respond at run time according to the actual class of the object to which they refer.

Biology Dictionary

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

Glossary

Definition: Difference in DNA sequence among individuals that may underlie differences in health. Genetic variations occurring in more than 1% of a population would be considered useful polymorphisms for genetic linkage analysis. the presence of several distinct forms of a gene or phenotypic trait within a population with frequencies greater than 1 percent.

COPYRIGHT 2000-2003 WEBNOX CORP. HOME | ABOUT HYPERDICTIONARY

Notes from ZDNet C++ Tutorial EK-1777

ZDNet C++ Tutorial EK-1777 sample lesson, Overview of Polymorphism (see CppTutorialZdnetEK1777 for my evaluation of the tutorial)

Focusing on polymorphism in C++:

Four features of C++ allow for polymorphism:

  • operator overloading (distinguished from overriding, discussed more below)
  • inheritance
  • virtual methods
  • generic container objects

Everyday example of polymorphism: An automobile and a sailboat can both move, but by very different "mechanisms" — nevertheless, you could give a "move command" to each, and each would move using its mechanism.

You can override a virtua method if it has the same (name and) signature:

  • name
  • (type of) return value
  • same number, type, and order (calling sequence) of parameters

Expound on:

  • overload: alternative
  • override: replace

Some other terms to understand:

  • class hierarchy
  • polymorphic cluster
  • virtual keyword

A computer oriented statement: The message sent to each (object::)method in a polymorphic cluster is the same, but the result varies depending on the object. (automobile::move vs. sailboat::move). (Is "::" the correct syntax?)

So what good is polymorphism?

  • Well since other people may use it and talk about it, you (I) at least need to have some idea what they're talking about. wink

  • I can sort of think of places where it might be useful, but they usually seem to be artificial situations (computer programming exercises) — when I come across a really useful example I'll have to note it here (and, as an aside, Python's use of object orientation is giving me another perspective (vs. the old examples I encountered of, for example, a toaster as an object, and then my realization that a (GUI) widget made more sense to me as an example of an object, but my recent experiences with Python (some good, some wierd), including the concept of join being a method of a string (like \n.join(<list of strings) seems to be a different viewpoint.

It will probably be worth my while to go through the tutorial again. It might also be worth exploring more of the tutorial, especially if I can get access for a few months for $6.95/month versus buying it for ~$100.

PS: The tutorial is not part of Biznet, but is available for about $80 at CNET help.com — if anybody wants to sell a used copy for a lot less than that, write to me. (Or put a note here, I usually find such notes as I monitor the site almost every day.)

Hierarchy Clues

One object is being defined as a more specific occurrence of another object.

The entire hierarchy of objects is termed a polymorphic cluster. Polymorphic because, in certain situations, you will be able to think of a specific object (low in the hierarchy) as if it was a more general object (higher in the hierarchy).

Contributors

  • () RandyKramer - 22 Oct 2003
  • If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.

Revision Comment

  • %DATE% —

Page Ratings

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2003-10-25 - RandyKramer
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look