Base cases that take dependencies upon information potentially supplied by 
subclass have to be intentionally design to make that work. And the chosen 
design should be document as part of its subclassing contract.  For the example 
shown there  is there is a long known pattern that can be used:

  class Base {
        constructor() {
             ....
             .. idAttribute ..
             ....
        }
        idAttribute = this.__idInitializer();  //initial id value may be 
supplied by a subclass
        __idInitialier() {
            // override this method if you want your subclass to provide an 
alternative initial idAttribute value
            // the subclass override method should not be dependent upon 
subclass fields.
            return ‘id’;
       ’}
    }

   class Derived extends Base {
        constructor() {
             super();
             ....
        }
        __idInitializer() {return ‘_id’}
   }

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to