Is there a benefit from having a subclass method that only calls the overridden superclass method?

L Lansing :

While refactoring I came across the following method in a subclass:

public void disposeResultsTable() {
    super.disposeResultsTable();
}

What are the benefits to keeping this method rather than simply allowing the inherited superclass method to be called?

Malt :

The only technical reason I can think of is what Michael proposed in the comments - making a restricted method become public.

However, I can think of a few human reasons.

For instance, this could be a convenient place to place a breakpoint for debugging invocations of disposeResultsTable of the child class. Or perhaps this was meant as a placeholder - "remember to implement this method for this class", or maybe someone wanted to explicitly point out to the reader of this code that this class uses the parent's implementation of disposeResultsTable. There are probably a bunch more options.

Have you tried looking up the history of this piece of code in the VCS? Maybe there's a helpful commit message from the original author.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=138842&siteId=1