I found this question: Two Interface with Same Method Name - Implementation of Methods
So if a class implements two interfaces, there is a problem:
Suppose the interface
Foo
specifies aFoo
methoddoStuffX()
, and interfaceBar
specifiesdoStuffY()
. Someone implements lets a classFooBar
implement booth interfaces.Later, it is realized that
Foo
needs access to adoStuffY
implementation, but with a different slightly different specification that makes sense in the context of Foo.Now, when a
FooBar
is passed to any method that accepts aFoo
and relies ondoStuffY()
may break.
So, my conclusion is that one should not implement more than one interface. Is that correct? Are there any techniques other than inner classes that can be used to add context names to interface methods. I thought of passing Foo
and Bar
references to them. Are there more ways?