0

This is a question about terminology in OOP.

Lets assume you have two classes A and B, with

class A extends B {}

Now B has a method called doSomething(), which it calls in its constructor.

class B {
  constructor() {
    this.doSomething();
  }
  doSomething() {
    /* some functionality almost all classes extending B need */
  }
}

Now unfortunately A neither wants nor needs what happens when B's constructor calls doSomething(). It is even harmful to instances of A.

Object orientation offers the option to overwrite (or is it override?) the method in the inheriting class:

class A extends B {
  constructor() {
    super(); // calls the contructor of B
  }
  doSomething() {
    this.doNothing();
  }
  doNothing() { 
    return;
  }
}

My question:

Is there a specific term in object orientation that describes exactly this way of overwriting/overriding an inherited method with a method that neutralizes the inherited methods functionality by basically doing nothing? How do you call A's doSomething()?

connexo
  • 53,704
  • 14
  • 91
  • 128
  • "*overwrite (or is it override?)*" - see https://stackoverflow.com/q/8651562/1048572 for that – Bergi Apr 23 '20 at 18:21
  • @Bergi thanks for that part. Any idea as of the main question? Is it a `stub`, a `dummy`, what is it called? I'd assume there is a specific term for such a method. – connexo Apr 23 '20 at 18:39
  • Regarding that, I have no idea. The terms [strategy](https://en.wikipedia.org/wiki/Strategy_pattern) and [noop](https://en.wikipedia.org/wiki/NOP_(code)) appear related, but the scheme as a whole seems uncommon enough to not have an established name. Usually, overriding is used the other way round. – Bergi Apr 23 '20 at 18:47

0 Answers0