Scriptaculous and Why 'extends' is Evil
The extends keyword is evil—maybe not at the Charles-Manson/Vlad-the-Impaler level, but bad enough that reputable designers don't want to be seen in public with it. The Gang-of-Four Design Patterns book is, in fact, largely about replacing implementation inheritance (extends) with interface inheritance (implements).
-- Allen Holub, Holub on Patterns: Learning Design Patterns by Looking at Code
Now I like using Scriptaculous, but
Object.extends makes far too many appearances in it for my taste. Pretty much every effect is implemented by extending
Effect.Base. The only exception is
Effect.Parallel, which allows you to compose two simple effects. The resulting code is somewhat messy and difficult to modify, since the design mixes two different concerns in a single object: the scheduling of the effect and the actual DOM modification that achieves the effect.
Having started the porting of Scriptaculous to GWT (GWTaculous), I was very tempted to replace inheritance with something like the Command pattern, essentially composing the scheduling part of the effect with the DOM modification part, as mentioned above.
Right now, changing
Effect.Base is extremely difficult, as doing so would break all of the effects subclasses (the Fragile-Base-Class problem, as Holub calls it). A clearly defined command interface would simplify that immensely.
extends necessary. Nice.
extends with mistrust. Most times, there is a better (in OO terms) way.