Is it standard practice to delete or comment out the code within an overridable function of a base class?

I spent 45 minutes arguing with my teacher about this today, and it seems stupid to me but maybe she just wasn't explaining it well.

She was trying to tell me that I one should comment out or delete the code block within an overridable function of the parent class when you make a child class with a function that overrides it.

Is there anything to this?

Answers


Definitely not. Just because one class overrides it doesn't mean that other classes that inherit from the base class would do the same. So in those cases you definitely want the base class functionality to remain there.

And then there is the point that dotNET has already made (child class needing to call base class's function to reuse the functionality already present there)


She was trying to tell me that I one should comment out or delete the code block within an overridable function of the parent class when you make a child class with a function that overrides it.

Lol wut?

  • What if the overriding method needs to call the overridable method?
  • What if another subclass is added that does not override the overridable method?
  • What if someone wants to call the overridable from its own (non-abstract) class?

That's a pretty bad idea.


Need Your Help

Comma separated list of selectors?

jquery jquery-selectors

I'm refactoring some code at the moment and have come across a selector:

Using JSP with Embedded Jetty 7 in Eclipse IDE, getting LogConfigurationException

java exception jetty logging nullpointerexception

I've included all jars the application requires, I'm trying to use Jetty Embedded