As I understand, one important difference between the 2 is that extends provides the parent() function. Because of this, it only allows one Extend (whereas Implements allows an array of Classes), and it is also much more expensive. If all you want is extra functionality, without the instanceof and without parent(), use implement.
On Tue, Nov 2, 2010 at 11:58 AM, stratboy <[email protected]> wrote: > Hi! I'm currently redesigning my plugin (Milkbox), based on Mootools > 1.3, and as I do it, I want to be sure to clean up code and use best > practices. > > So a couple of questions: > > 1. What are, apart from the main one (the modification of prototype), > the practical differences of extending vs implenting Events? For > Milkbox, I just need to fire some simple event to listeners. Till now, > I always did it via Implement. Is it the best way? > > 2. Milkbox is not supposed to be instantiated more than once per page, > since there's no reason to build the viewer's html code more than > once. Instead there can be a lot of different galleries, and all use > the same viewer (so maybe I could code a MilkboxGallery class).. > Anyway, that said, if I want to prevent instantiation, should I use > some kind of singleton or is it better to simply put some arbitrary > internal check? Or maybe there's some other better pattern? > > Bye (and thanks)! > > > > > > -- Arieh Glazer אריה גלזר 052-5348-561 5561
