|
-
Mar 24th, 2006, 01:01 PM
#1
Thread Starter
Frenzied Member
Variables and Interfaces
I am creating an object that implements quite a few interfaces. My problem is that there are a couple of variables that all the interfaces need access to. I know that I could put these variables in a module or shared class, but that is generally a sign of poor OOP design.
Is there any way that I could implement this without using global variables?
Here is a sample of the layout of the object. In the sample the Interfaces need to be able to get what the CurrentIndex is, but I don't want them to be able to change it at all. It should only be writeable from MainObject.
VB Code:
Public Interface MainObject
ReadOnly Property CurrentIndex as Integer
ReadOnly Property If1 as Interface1
ReadOnly Property If2 as Interface2
ReadOnly Property If3 as Interface3
Function SetCurrentIndex(index as Integer)
End Interface
Public Interface Interface1
ReadOnly Property P1 as Something
ReadOnly Property P2 as Something
ReadOnly Property P3 as Something
ReadOnly Property P4 as Something
Function F1(ST as Something) As Something
Function F3(ST as Something) As Something
Function F2(ST as Something) As Something
End Interface
Public Interface Interface2
ReadOnly Property P1 as Something
ReadOnly Property P2 as Something
ReadOnly Property P3 as Something
ReadOnly Property P4 as Something
Function F1(ST as Something) As Something
Function F3(ST as Something) As Something
Function F2(ST as Something) As Something
End Interface
Public Interface Interface3
ReadOnly Property P1 as Something
ReadOnly Property P2 as Something
ReadOnly Property P3 as Something
ReadOnly Property P4 as Something
Function F1(ST as Something) As Something
Function F3(ST as Something) As Something
Function F2(ST as Something) As Something
End Interface
-
Mar 24th, 2006, 01:26 PM
#2
Re: Variables and Interfaces
I haven't done anything with interfaces, but I was always under the impression that an interface exposed a set of properties and functions from an underlying object. Is that not the case?
My usual boring signature: Nothing
 
-
Mar 24th, 2006, 01:30 PM
#3
Thread Starter
Frenzied Member
Re: Variables and Interfaces
What happens is that the main object is exposing the properties and functions from the other interfaces. But those interfaces need to know a couple of variables that is in the MainObject interface. I hope that makes sense (and I hope I am doing it right). This is the first time I have dealt with interfaces. I had a nice pretty class that worked, then my boss said he wanted it done with interfaces.
-
Mar 24th, 2006, 02:50 PM
#4
Thread Starter
Frenzied Member
Re: Variables and Interfaces
Ok....Here is what I thimk I am going to do. I'd like to know if this is a good way or not to do it. And if not what is a better way. I am creating properties in the classes that get implemented, but I am not adding them as part of the interface. That way MainObject can access these properties, but they can not be accessed through the interface. Let me know what you think.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|