Not forcing super in derived class's constructor?

Glen Huang curvedmark at gmail.com
Wed May 13 03:02:10 UTC 2015


> maybe subclassing that particular class is not the correct abstraction here;

I think the need for inheriting methods and the need for a totally different way of preparing the object are orthogonal.

> correct the design of the super-constructor, so that it is able to just do the minimum required stuff.

This sounds like the correct way of doing things, but the reality is usually that when someone writes the base class, it might not be obvious that it will be derived, so the base class isn't designed with some param combination will just do the minimum required stuff, and when people do want to derive it, providing a new constructor(), they are unable to ask super to just provided an untouched new object.

>  there is the following possibility that I don't propose very seriously

Didn't think of this method before, thanks for the heads up. But it's imperative and rely on the fact that "extends" currently only sets the prototypes of two object. I'm afraid it won't be enough once "extends" does something more in a later spec.

I wonder what's so terrible about creating a new object when there is no super that you just want to avoid it?


More information about the es-discuss mailing list