Differential inheritance
Encyclopedia
Differential Inheritance is a common inheritance
Inheritance (object-oriented programming)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

 model used by prototype-based
Prototype-based programming
Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as classless, prototype-oriented or instance-based programming...

 programming languages such as JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

, Io and NewtonScript
NewtonScript
NewtonScript is a prototype based programming language created to write programs for the Newton platform. It is heavily influenced by the Self computer language, but modified to be more suited to needs of mobile and embedded devices.- History :...

. It operates on the principle that most objects are derived from other, more general objects, and only differ in a few small aspects; while usually maintaining a list of pointers internally to other objects which the object differs from.

An Analogy

To think of differential inheritance, you think in terms of what is different. So for instance, when trying to describe to someone how Dumbo
Dumbo
Dumbo is a 1941 American animated film produced by Walt Disney and released on October 23, 1941, by RKO Radio Pictures.The fourth film in the Walt Disney Animated Classics series, Dumbo is based upon the storyline written by Helen Aberson and illustrated by Harold Pearl for the prototype of a...

 looks, you could tell them in terms of elephants: Think of an elephant. Now Dumbo is a lot shorter, has big ears, no tusks, a little pink bow and can fly. Using this method, you don't need to go on and on about what makes up an elephant, you only need to describe the differences; anything not explicitly different can be safely assumed to be the same.

External links

  • Differential inheritance in JavaScript (Mozilla Developer Center
    Mozilla Developer Center
    Mozilla Developer Center , started in early 2005, is the official Mozilla Foundation website for development documentation and news about Firefox, Thunderbird, and other Mozilla Foundation projects. It is intended to supplant the community-driven aspect of documents authored for the mozilla.org...

    article)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK