Should one interface inherit another interface

后端 未结 6 1940
抹茶落季
抹茶落季 2021-01-30 12:17

I can\'t seem to find an answer on this and just want to make sure it\'s an ok coding standard. I have interface A that is used by many different classes and don\'

6条回答
  •  情话喂你
    2021-01-30 12:48

    It is certainly possible to have an inheritance tree of interfaces, and even "multiple inheritance" with interfaces. Whether it is the right thing to do or not depends on the interfaces in question. If it really is the case that interface B is an extension or refinement of interface A, then inheritance makes sense, but if the new enum is largely unrelated to the concept expressed by interface A, I would make them two separate interfaces and have the classes that need to implement both interfaces.

提交回复
热议问题