Multiple Interfaces

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
Interfaces are a sort of contract which states that the implementing object must implement all methods of the interface. Fine. But at the next level up you might have several related interfaces, and want to have a contract that a dll will implement all of those interfaces, and do so just once. Can this be done? Or am I better thinking of having one big interface and somehow dividing the procedures in that into categories?
 
You could create an interface that inherits the other smaller interfaces and then have the class inside the dll implement that interface - that way it can still be used where ever any of the interfaces are required also.
 
PlausiblyDamp said:
You could create an interface that inherits the other smaller interfaces and then have the class inside the dll implement that interface - that way it can still be used where ever any of the interfaces are required also.
Yes, that's pretty good, thanks. It would still be quite neat if I could somehow prevent the interface from being implemented more than once in a dll, to avoid the confusion it would cause. But probably there's no easy way of doing that.
 
Well you're not going to call functions on the DLL, you're going to call functions on a class in the DLL. Just don't put any other class' in the DLL that use the interface.
 
A dll is going to expose classes to other applications, it's these classes that implement the interface(s) not the DLL itself.
Not sure how each class that is required to implement a particular interface actually implementing the interface is likely to cause confusion though...
 
PlausiblyDamp said:
A dll is going to expose classes to other applications, it's these classes that implement the interface(s) not the DLL itself.
Not sure how each class that is required to implement a particular interface actually implementing the interface is likely to cause confusion though...
If a dll implements the interface more than once in different classes then that's not what I would be expecting. But fine, it just means I have two plug-ins in the same dll, which is no great problem, true, I just have to write a little code for it.
 
rbulph said:
If a dll implements the interface more than once

A dll doesn't implement anything it's simply a library of classes. Any or all of the classes in the dll can implement the same interface. The fact that classes are all in the same dll doesn't link them in any way other than the fact that they are stored together.
 
Back
Top