Search code examples
classmootoolsextends

Mootools "Extends" plus "Implements"


I like to write my code slim and sexy (on the performance and memory side), I am using Mootools and was wondering if I was using it the correct way, also you can help me by telling me how to test my code to find the answers I am looking for my self.

//First we create a class like so:

var FirstClass = new Class {(
   'someFunc': function() { /* do stuff */ }
})

//Now this class uses first class with "Implements"

var SecondClass = new Class ({
   'Implements': [FirstClass, SomeOtherClass, SomeOtherOtherClass],
   'iAlsoDoStuff': function() {/*do stuff */}
})

// finally the class that Extends second class
var ThirdClass = new Class ({
   'Extends': SecondClass,
   'takeOverTheWorld': function() {/*code to win lottery */}
})

How can I tell if every time secondclass is extended it doesnt make a new copy of the Implemented classes? The reason I am doing what I am doing above is to Extend SecondClass for every class that needs it - doing so statically, while the second class cannot extend more then one class thus I am using Implements.


Solution

  • I finally got my answer on the Mootools google group, thought I would update it here in case some one finds interest in it.

    http://groups.google.com/group/mootools-users/browse_thread/thread/5aec78813fa51cc1

    Enjoy! Roman