Open domenic opened 10 years ago
My first thought was "Please no!"
Aggregation and delegation tend to make much more useful pieces. I think subclassing forces bad design more often than good.
What I mean by that is it forces you to do things like define Promise.prototype.catch
to call this.then
, instead of defining it to use a magic algorithmic series of steps. In the former case, people not only get the desired subclassing behavior of only having to override then
on their subclass, but they also get a consistent mental model of what catch
does, besides "something in C++." That's why subclassing-friendly design is often good design.
Now that's a good thing. (though subclassing a promise?! That doesn't sound smart at all)
User extensibility, forces good design, etc. Lots of examples for this section would be good.