Inheritance 没有方法的子接口
所以我有一个父接口,还有一些子接口,一些有实现,一些没有Inheritance 没有方法的子接口,inheritance,design-patterns,interface,Inheritance,Design Patterns,Interface,所以我有一个父接口,还有一些子接口,一些有实现,一些没有 interface IParent { void A(); void B(); } interface IChild1 : IParent { void C(); } interface IChild2 : IParent { // empty, just inherits } 这是好的做法吗?如果没有,那么更好的方法是什么?通过引入一个没有任何新方法的接口,您希望实现什么?我有一个接口,其中包含许多
interface IParent {
void A();
void B();
}
interface IChild1 : IParent {
void C();
}
interface IChild2 : IParent {
// empty, just inherits
}
这是好的做法吗?如果没有,那么更好的方法是什么?通过引入一个没有任何新方法的接口,您希望实现什么?我有一个接口,其中包含许多子接口的常用方法,但在这种情况下,子接口将没有任何具体的实现方法。在代码的其他部分中,我总是引用子接口,因此不创建它会导致直接引用基类,可能会提供如何使用子接口的示例。如果空接口只是为了让您的代码更具可读性-好吧,但它不寻常,其他阅读您的代码的人可能会想:-)。