473,320 Members | 1,817 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.

How do I make objects implement both interfaces


I have an interface called Lockable and an interface called
TableObject. How do I make sure that any class which implements
Lockable also implements my other, TableObject interface?

Do I have to copy the definition of the TableObject interface into
Lockable? I'd rather not do that incase I need to downcast them to
simple TableObject's later.

Sep 26 '07 #1
3 1372
You could likely have interface TableObject inheriting from interface
Lockable :

Interface TableObject
Inherits Lockable
' Add TableObject specifics here
End Interface

--
Patrice

"Phillip Taylor" <Ph*****************@gmail.coma écrit dans le message de
news: 11**********************@19g2000hsx.googlegroups.c om...
>
I have an interface called Lockable and an interface called
TableObject. How do I make sure that any class which implements
Lockable also implements my other, TableObject interface?

Do I have to copy the definition of the TableObject interface into
Lockable? I'd rather not do that incase I need to downcast them to
simple TableObject's later.

Sep 26 '07 #2
Phillip Taylor wrote:
There IS a logical and application driven needs to one onto the other.

Take my exact requirements as stated in the original post: I have
objects or type "TableObject" (which signifies this the "Active
Record" approach to development). It makes perfect sense that you can
only implement Lockable objects on actual TableObjects. I mean you
can't lock something which isn't in the database. Hense if someone
implements Lockable, I want to force them to be sure that they've
implemented TableObject first.
Interface inheritance sounds like the way to go.

Interface ITableObject
Sub X()
Sub Y()
End Interface

Interface ILockableTableObject
Inherits ITableObject
Sub Z()
End Interface

Dim t1 as ITableObject
Dim t2 as ILockableTableObject

Sub HandleTable( t as Object )
If t Is ITableObject Then
With DirectCast( t, ITableObject )
. . .
End With

If t Is ILockableTableObject Then
With DirectCast( t, ILockableTableObject )
. . .
End With
End If
End If
End Sub

HTH,
Phill W.
>
Sep 26 '07 #3
On Sep 26, 2:43 pm, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
Phillip Taylor wrote:
There IS a logical and application driven needs to one onto the other.
Take my exact requirements as stated in the original post: I have
objects or type "TableObject" (which signifies this the "Active
Record" approach to development). It makes perfect sense that you can
only implement Lockable objects on actual TableObjects. I mean you
can't lock something which isn't in the database. Hense if someone
implements Lockable, I want to force them to be sure that they've
implemented TableObject first.

Interface inheritance sounds like the way to go.

Interface ITableObject
Sub X()
Sub Y()
End Interface

Interface ILockableTableObject
Inherits ITableObject
Sub Z()
End Interface

Dim t1 as ITableObject
Dim t2 as ILockableTableObject

Sub HandleTable( t as Object )
If t Is ITableObject Then
With DirectCast( t, ITableObject )
. . .
End With

If t Is ILockableTableObject Then
With DirectCast( t, ILockableTableObject )
. . .
End With
End If
End If
End Sub

HTH,
Phill W.

Thanks guys.

Sep 26 '07 #4

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

Similar topics

49
by: Steven Bethard | last post by:
I promised I'd put together a PEP for a 'generic object' data type for Python 2.5 that allows one to replace __getitem__ style access with dotted-attribute style access (without declaring another...
2
by: Wayne Phipps | last post by:
I'm trying to get my head around objects and am asking for thoughts on this idea. If for example I were to implement a Person Object, there may be differnt Person objects representing people of...
1
by: Inon Zukerman | last post by:
hello everyone. My problem is as follows : my application keeps a hashtable with Outlook.MailItem objects. I need to save and load this hashtable (with those objects inside) when starting and...
48
by: Andrew Quine | last post by:
Hi Just read this article http://www.artima.com/intv/choices.html. Towards the end of the dicussions, when asked "Did you consider including support for the concept of immutable directly in C#...
2
by: Marc Scheuner [MVP ADSI] | last post by:
Folks, Has anyone done this before? (I'm sure some of you guys have) I'd like to make sure our business objects and collections thereof are created in such a way that we can connect them to a...
38
by: Radi Radichev | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines...
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
31
by: JoeC | last post by:
I have read books and have ideas on how to create objects. I often create my own projects and programs. They end up getting pretty complex and long. I often use objects in my programs they are...
12
by: =?iso-8859-1?q?R=E9my_Sanchez?= | last post by:
Hello, I'm trying to use MSCOMM32.OCX, but I got an error "Fatal error: Uncaught exception 'com_exception' wih message 'Failed to create COM object 'MSComm32.OCX' : Incorrect syntax' The OCX...
8
by: Charles Law | last post by:
This is a sort of pattern question, but relating to how components are coupled in a three-tier system. I have a presentation layer, business layer and data access layer, the first is the EXE,...
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...
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
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.