Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding method only calls parent method - useful?

I was looking through an old codebase and I found a method that only calls its parent:

@Override
public void select(Object item) {
  super.select(item);
}

Would there be any use case for such a method? For me it looks like I could just remove it.

like image 649
jhyot Avatar asked Mar 10 '15 12:03

jhyot


2 Answers

Removing it would make almost no difference. You will see a difference when using reflection and looking for the select method on the object. If you ask tell reflection not to look in the object's base class, it's not going to find the method after you delete it.

like image 113
zmbq Avatar answered Oct 12 '22 01:10

zmbq


Yes, this method can be removed without changing the logic of your code.

Perhaps it used to have a different implementation which was removed, or was supposed to have a different implementation which was never written.

like image 43
Eran Avatar answered Oct 12 '22 02:10

Eran