Fergus,
It has dual identity: To the Car class itself the method is Private. However
because it has the Implements ICloneable.Clone on the declaration is it
Public to the ICloneable interface.
Which means if I have an ICloneable variable with a Car object in it. I can
use the Clone method and the Car.ICloneable_Clone method will be called
transparently by the Framework. However If I have a Car variable with a Car
object in it, only methods inside Car can call it.
Which I find is part of the beauty of the how VB.NET Implements works. If
you use C# it has a similar ability using "ICloneable.Clone" for the method
name which actually hides it from the Car class itself, you can only access
the method via the interface. In VB.NET I can do:
Public Function CreateCopy() As Object Implements ICloneable.Clone
I renamed the ICloneable.Clone method in the public interface of Car. C#
needs two functions to do the above! One for the CreateCopy method, and one
to hide ICloneable.Clone.
Which is also why if you look at the "Windows Form Designer generated code"
section of a form you will occasionally see:
CType(Me.grid, System.ComponentModel.ISupportInitialize).BeginIni t()
The Forms designer knows that the object in the grid variable implements the
ISupportInitialize interface, but the BeginInit method may be hidden or
renamed using the above technique.
NOTE: Some OOP developers/designer feel it is wrong to hide the
implementation of an interface. That when you say a class Implements an
Interface that all methods of that Interface need to be public "as per the
interface definition", which follows the inheritance rule, this Class IS A
this Interface. I tend to relax a little on this point, as Implementing the
Interface may be an Implementation detail (such as ISerializable). The
ISerializable.GetObjectData may be an implementation detail in which case it
should not be public. The fact my object is Serializable & supports the
ISerializable interface is an implementation detail. Either way you feel, it
is advantageous that .NET (VB.NET & C#) supports the ability.
Hope this helps
Jay
"Fergus Cooney" <fi****@post.com> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
Hi Jay,
How come the Private member is available through the Interface? Does
being an Interface implementation method override this privacy. No, another
view - does it have a dual identity - Private in its Car guise yet Public as an
ICloneable method? Is this the OOP version of superheroes like
Batman/Bruce Wayne? (forget that last question, lol)
Regards,
Fergus