trans-mission / cyto-project

The creative genome
0 stars 0 forks source link

Inheritance Patterns #11

Open mmansion opened 10 years ago

mmansion commented 10 years ago

There needs to be a better inheritance pattern for creation of drawing primitives, not unlike the hierarchy within the CreateJS framework.

From the MDN page on Object.create there is a simple example for one-class inheritance model. They also suggest mixins for multiple inheritances, similar to jQuery's object extend.


function MyClass() {
     SuperClass.call(this);
     OtherSuperClass.call(this);
}

MyClass.prototype = Object.create(SuperClass.prototype); // inherit
mixin(MyClass.prototype, OtherSuperClass.prototype); // mixin

MyClass.prototype.myMethod = function() {
     // do a thing
};