Tight on the heels of my article on the evils of ‘extends’ and Scriptaculous, Bernard Sumption, the author of Animator.js, has expounded on why he thinks it is evil and must be destroyed.
All of the pain caused by inheritance can be traced back to the fact that inheritance forces ‘is-a’ rather than ‘has-a’ relationships. If class R2Unit extends Droid, then a R2Unit is-a Droid. If class Jedi contains an instance variable of type Lightsabre, then a Jedi has-a Lightsabre.
The difference between is-a and has-a relationships is well known and a fundamental part of OOAD, but what is less well known is that almost every is-a relationship would be better off re-articulated as a has-a relationship.
As I’ve already pointed out, composition is to be preferred over subclassing in most cases, and that the GoF patterns are all about replacing implementation inheritance (extends) with interface inheritance (implements). Combine this with Larman’s GRASP patterns, and you see that much of the thrust of OOAD is about working around the limitations of "extends."
Technorati Tags: ajax, javascript, ooad, patterns

As far as I am concerned I must congratulate you both on having re-invented LSP about 30 years after it first saw daylight…
Nothing new here except that the author has completely overlooked MI…!
Imagine this;
class DarkPowers {}
class Android {}
class DardkAndroid : extends Android _&&_ DarkPowers {}
Fact is for everybody that’s done more than slightly advanced C++ MI solves most of the IS A/HAS A problems that Java and C# suffers from…
So does also JavaScript…
Look at this one for instance; http://smartwin.cvs.sourceforge.net/smartwin/SmartWin/include/smartwin/widgets/WidgetTextBox.h?revision=1.39&view=markup
The above class is an extremley beautiful example of using IS A in a Multiple Inheritance environment without ever even being CLOSE to breaking Mrs. Liskow Substitution Principle what-so-ever…!
I’m doing the exact same thing in JavaScript too in fact…!
So unless you want to type out forward methods to a gazillion methods using “HAS A” you can easily utilize MI to inherit from a truckload off classes…
Though from a single inheritance view I must confess I kind of agree…
MI though goes completely ballistic with your entire thesis…
.t
Douglas Crockford wrote a witty post about .extends a couple of years back. Check it out here:
http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=440