473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Changing Interface or Inheritance base classes

I could use a little advice to help prevent me making a possible mess of a
project. :)

In VB6, I once created a project that exposed a public interface class. I
then Implemented this in various plug-in DLLs so that I could early-bind to
the plug-ins by declaring objects of the interface class type.

This worked fine, until one day I found that I needed to add a new method to
the interface class. Of course, everything broke immediately after I had
done this as adding a new method changed my class's interface. All the
plug-ins that implemented the old interface no longer recognised the new one
and I made a big mess that took a lot of time to clear up.

This was all based around COM and CLSIDs, neither of which are relevant in
VB.NET. Will I have similar problems if I try to change an interface class
in a VB.NET project (assuming that I get the plug-ins to bind to the new
version and not the old)?

In addition to this, I've also been trying to achieve the same objective
with inheritance in VB.NET. I have a base class that has a variety of
functions that are declared either Overridable (where the function has a
default implementation in the base class) or MustOverride (where the derived
class has to implement its own functionality). I then get my plug-ins to
inherit this class. Code that uses the plug-ins can early bind by declaring
objects of the base class type.

My assumption is that I can then add new methods to the base class,
providing I make them Overridable instead of MustOverride, and the derived
classes will continue to function when bound to this modified version of the
class. Any calls to the new functions that are unrecognised by the plug-ins
will fall through to the base class implementation. Am I correct here, and
are there are problems that I may encounter by doing this?

My thanks in advance,

--

(O) e n o n e
Nov 21 '05 #1
2 1754
I think the generally accepted method of creating new interfaces without
breaking existing ones is to create an entirely new interface that derives
from the existing one. Say instead of PlugMeIn_Interface, derive a new one
called PlugMeIn_Interface2, deriving from PlugMeIn_Interface. Now, you add
the new methods to the new interfaces without changing the way the old
interface works. Any new plug-ins you make will utilise the new interface,
but old ones obviously cannot (because they don't know about it).
"Oenone" <oe****@nowhere.com> wrote in message
news:mN****************@newsfe1-gui.ntli.net...
I could use a little advice to help prevent me making a possible mess of a
project. :)

In VB6, I once created a project that exposed a public interface class. I
then Implemented this in various plug-in DLLs so that I could early-bind
to
the plug-ins by declaring objects of the interface class type.

This worked fine, until one day I found that I needed to add a new method
to
the interface class. Of course, everything broke immediately after I had
done this as adding a new method changed my class's interface. All the
plug-ins that implemented the old interface no longer recognised the new
one
and I made a big mess that took a lot of time to clear up.

This was all based around COM and CLSIDs, neither of which are relevant in
VB.NET. Will I have similar problems if I try to change an interface class
in a VB.NET project (assuming that I get the plug-ins to bind to the new
version and not the old)?

In addition to this, I've also been trying to achieve the same objective
with inheritance in VB.NET. I have a base class that has a variety of
functions that are declared either Overridable (where the function has a
default implementation in the base class) or MustOverride (where the
derived
class has to implement its own functionality). I then get my plug-ins to
inherit this class. Code that uses the plug-ins can early bind by
declaring
objects of the base class type.

My assumption is that I can then add new methods to the base class,
providing I make them Overridable instead of MustOverride, and the derived
classes will continue to function when bound to this modified version of
the
class. Any calls to the new functions that are unrecognised by the
plug-ins
will fall through to the base class implementation. Am I correct here, and
are there are problems that I may encounter by doing this?

My thanks in advance,

--

(O) e n o n e

Nov 21 '05 #2
Robin Tucker wrote:
I think the generally accepted method of creating new interfaces
without breaking existing ones is to create an entirely new interface
that derives from the existing one.


Hi Robin,

Thanks for your reply. That was the conclusion we came to too in the end
(back in VB6), but we decided it was more trouble than it was worth in the
end and just late-bound to the components.

Do you (or anyone else) have any comments on the inheritance method I
described? This it the one I really want to go with in VB.NET but I'm not
quite at the point of being able to test it yet...

Thanks,

--

(O)enone
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: christopher diggins | last post by:
A feature that I find signficantly missing in C# is the ability to write functions in interfaces that can call other functions of the interface. Given an interface ISomeInteface the only way we can...
13
by: Just D | last post by:
All, What are advantages and disadvantages of these two different approaches? 1 . I create a base class with a few virtual methods, then I derive my classes from this class, override these...
9
by: phl | last post by:
hi, I am kind of confused aobut interfaces and abstract classes. In short as I understand it, an interface is like a contract between the class and the interface, so that certain funtions must...
7
by: Hazz | last post by:
Are there any good references/articles/books which provide clarity toward my insecurity still on deciding how to model a complex system? I still feel uncomfortable with my understanding, even...
13
by: John Salerno | last post by:
Hi all. I have a question about interfaces now. According to the book I'm reading, when you implement an interface, the class or structure has to declare all the methods that the interface...
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
15
by: mr.peteryu | last post by:
Hi, Can someone explain the idea behind casting to an interface? For example: -> I have an IInterface that contains a Read() method. -> I have an object "obj" that implements IInterface. ...
4
by: Raja Chandrasekaran | last post by:
Hai friends, I really wonder, If the interface does not have any definition, Y do we need to use interface. You can then only we can use Multiple inheritance. I really cant understand, Just for...
17
by: Zytan | last post by:
Aren't all classes interfaces? What constitutes an interface (and with it, the "I" prefix distinction)? Zytan
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.