Re: hiding an interface (VB6)

From: Ralph (nt_consulting32_at_hotmail.com)
Date: 04/30/04


Date: Fri, 30 Apr 2004 10:29:16 -0500


"Mark Meyers" <mmeyers[at]hydromilling.com> wrote in message
news:uGDXoKrLEHA.2456@TK2MSFTNGP12.phx.gbl...
> Using VB 6...
> I have an object (MyObject) that I would like to be able to contain a few
> values, and its reference be passed off to other objects interested in
> receiving it. However; I would like for the recipients to receive only
the
> ability to call the read functions of the object passed, I do not want
them
> to even be able to get to the write members.
>
> And yet, I want on the object owner's side the ability to call the write
> members.
>
> It looks like the only 'friend' I've got in VB is one where the class
become
> public to everything in the project. Is that true? Aside from friend
> access, I don't know how to achieve the desired results.
>
> The closest thing I have come up with is having an Init() function that
> ensures that it is only called once, and where the Init() function is the
> only way to set values in the object. Then, the object recipient could
try
> to call Init(), but that wouldn' work, and so the recipient can only
access
> the read members.
>
> One other idea is to implement two interfaces in MyObject. One with read,
> the other with write, members. The recipients use refs to one interface,
> the owner has refs to the both. The only problem with this, technically,
is
> the recipient still has the ability to knowingly go and establish a
> reference to the other interface, causing it to become publicly accessible
> as well.
>
> - Mark

One hack is to create an 'owner key'. The owner or creator of your class
creates a key when Init() is called. All subsquent calls to the default
interface must contain the key and are compared to the original and ignored
if the key is not valid. Any object using the 'read' interface doesn't need
a key.

-ralph



Relevant Pages

  • Re: php 5 classes: public, protected and private
    ... Private members can be accessed by members of the class only. ... Intefaces are not necessary in PHP. ... Once you have defined a method it is a total waste to time to also define an interface. ... Encapsulation means the internals of an object are managed only by that object and are not available to anyone else. ...
    (comp.lang.php)
  • Re: php 5 classes: public, protected and private
    ... Private members can be accessed by members of the class only. ... Intefaces are not necessary in PHP. ... the interface is the way to interact with the ... Two of the concepts in OO are 'encapsulation' and 'methods'. ...
    (comp.lang.php)
  • Re: How to email "Undisclosed Recipients"
    ... > Undisclosed Recipient I get or any mail not addressed to me, ... > reads "Alumni Members Monthy Newsletter" and then the people it ... select the folder in which you want ... Select a directory service from the drop-down list ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: php 5 classes: public, protected and private
    ... Private members can be accessed by members of the class only. ... Intefaces are not necessary in PHP. ... Once you have defined a method it is a total waste to time to also define an interface. ... Encapsulation means the internals of an object are managed only by that object and are not available to anyone else. ...
    (comp.lang.php)
  • Re: php 5 classes: public, protected and private
    ... Private members can be accessed by members of the class only. ... Intefaces are not necessary in PHP. ... Once you have defined a method it is a total waste to time to also define an interface. ... Encapsulation means the internals of an object are managed only by that object and are not available to anyone else. ...
    (comp.lang.php)