CSC/ECE 517 Fall 2010/ch1 4e dj
Page Stub for Dzoba and Jeremy for Prototype-based programming
Introduction
Prototype based programming is centered around the idea of developing object oriented code by developing functionality at the object level, and then abstracting the code into prototypes. This allows the programmer the ability to develop objects without the overhead of determining class relations, associations, and requirements.
Prototypes vs. classes
A class is a definition of an objects behavior and data fields. This definition generally does not change throughout the execution of the code.
A prototype is an object that is to be used as a basis for developing another object. Not only does a prototype contain data, but it also contains behaviors for the object.
Creation using each method
A class can be created through its constructor. This restricts creation to explicit calls to the new method of the class, and prevents changing the objects behavior after the object is instantiated.
A prototype may be created either ex nihilo or by cloning another class.
Inheritance in each method
A class based design requires that all relationships are created explicitly in the source. This means that for a class to be a child of another, that relationship must be explicitly stated in the source at compile time.
An object may have its functionality extended during execution by inclusion of a prototype. This means that a object can be given any aspect while the code is executing. See Unbounded Polymorphism
Negatives of Prototype based programming
References
http://www.c2.com/cgi/wiki?PrototypeBasedProgramming http://en.wikipedia.org/wiki/Prototype-based_programming