And, to quote from the Docs:
Implements is similar to Extends, except that it adopts properties from one
or more other classes without inheritance. Useful when implementing a
default set of properties in multiple Classes. The Implements property
should come after Extends but before all other properties


What you were referring when talking about the prototype was in fact the
implement method, and not the Implements property. So maybe this entire
answer was off...

If you were talking about the implement method, I understand it as a tool
that helps us modify a Class without modifying it's code (maybe to add a fix
to a 3rd party library).

On Tue, Nov 2, 2010 at 1:16 PM, אריה גלזר <[email protected]> wrote:

> 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
>
>


-- 
Arieh Glazer
אריה גלזר
052-5348-561
5561

Reply via email to