Brett wrote:
If one of the classes requires a new method, this means I have to add
this method to the interface and all involved classes. My design
breaksdown in this case and becomes high maintenance. Is there a
better approach to this scenario or some way to overload the
interface?
I examined the same problem and decided in the end to use inheritance
instead of interfaces to solve the problem.
I declared my base class as MustInherit, and into it I put all of the
properties and methods that I wanted my derived classes (plug-in DLLs in
this instance) to support. Some of the methods had to be implemented in the
derived classes, so I declared these as MustOverride. Others could be left
with either an empty implementation or could fall back to a default
implementation provided by the base class itself. These I declared
Overridable (after finally working out how to spell "Overridable").
This works very nicely; when I want to use one of the plug-ins, I can
declare an object with the type of the base class, and then set it to one of
the derived classes. This lets me early-bind to all the plug-in classes.
When I want to add a new property or method to the base class, as long as I
declare it as Overridable instead of MustOverride, everything continues to
work perfectly. You can therefore add as many new functions as you like,
providing they can fall back to the implementation in the base class when
the derived class doesn't override them.
--
(O) e n o n e