In Java when one interface extends another, why would one redeclare a method in a subinterface?

Having seen this happen on occasion while working for Sun, I can tell you how it usually happens. Someone defines an interface, let’s say Alice, with some methods; many developers implement that interface.

Some time later, it’s realized that they need some other interface, call it Bob, that has a subset of the methods of Alice, in order to allow it to serve as a base interface for another interface, Clara.

If you move the methods of Alice into Bob, you break all the code that implements Alice; you have to go back and at least recompile a whole bunch of code, some of which you may not own, and for political reasons can’t break.

So you don’t.

Leave a Comment