tags:

views:

25

answers:

3

Is it considered good practice or bad practice to write an interface that exists solely to concentrate other interfaces?

interface InterfaceA : InterfaceB, InterfaceC {
}

In doing this, a concrete implementation only needs to implement InterfaceA, which seems like a good thing, but it doesn't add any value by extending, which seems wasteful.

+1  A: 

If it makes sense, and you're going to be using all three interfaces independently, it can definitely be the appropriate design decision.

If it turns out that InterfaceB and IntefaceC won't ever be used, then just make InterfaceA...

Dave Markle
+1  A: 

It is indeed useful for maintaining code readability, then you can use the concrete implementation of interface A where interface B or C are required.

dvhh
+2  A: 

I think it depends on if it makes sense in your domain. If it does, I would do it, then your program more accurately models your domain.

In addition, of course, you can now write code which requires/uses objects implementing InterfaceA i.e. all methods of both the super-interfaces; that wouldn't have been possible before.

Adrian Smith
Marked as the accepted answer because, while all answers were correct, looking at it from the domain angle clinched it. It does indeed make sense within my domain and the answer would have been obvious had I thought from that angle.
oakskc