What is the benefit of extending an interface AGAIN which is already extended by its parent?

Jenix :

Say, I have below code:

interface IAAA {
    void aaa();
}

interface IBBB extends IAAA {
    void bbb();
}

class MyClass implements IAAA, IBBB {
    public void bbb() { }
    public void aaa() { }
}

Is there any benefit of implementing IAAA in MyClass? As you can see, IAAA is already extended by IBBB and MyClass is implementing both IAAA and IBBB. It seems removing IAAA from MyClass doesn't affect anything.

The reason why I'm asking this silly question is, I see this kind of patterns quite often in Android Open Source Project and sometimes even in the standard Java API such as ArrayList.

One example I want to talk about is SpannableStringBuilder.

Spanned interface extends CharSequence interface.

Spannable interface extends Spanned interface.

Editable interface extends both CharSequence and Spannable interface.

SpannableStringBuilder class implements CharSequence, Spannable, Editable interface AGAIN.

I really don't get it. What's the point of doing this way? Why bother?

Gabe Sechan :

There's no technical reason. It may make it a bit easier in maintenance- if Bar extends Foo and you want to find all the classes that implement Foo, you only have to look for Foo and not Foo and Bar.

Guess you like

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