On Jun 3, 2006, at 5:11 AM, Guyren Howe wrote:
On Jun 2, 2006, at 2:09 PM, Charles Yeomans wrote:
On Jun 2, 2006, at 2:58 PM, Jay Wooten wrote:
Suppose you create a custom canvas:
That canvas has a Getter/Setter pair to retrieve/store a string
in a property. Assume the canvas control is called myCanvas.
Sub SetText( theText as string)
MyText = theText
End Sub
and
Sub GetText() as string
return MyText
End Sub
You call the methods externally as such
myCanvas.SetText("some text")
and
someText = myCanvas.GetText()
Now lets say you make the daring decision to put the canvas
control inside a Containercontrol, but you still need to be able
to set/get the string stored in the canvas externally to the
Container.
Is it most appropriate to create a Getter/Setter pair of methods
for the Container Control that passes on the values on to the
myCanvas control?
i.e.
Container control methods:
Sub SetText( theText as string )
myCanvas.SetText(theText)
End Sub
Sub GetText() as string
return myCanvas.GetText()
End Sub
Or is there a better way to do this?
I think that this is precisely what you should do. You'll
appreciate it if, for instance, you decide to rename the canvas.
Computed properties are great for this sort of thing.
Note that this is an excellent example of a situation where a Class
Interface will let you treat either the canvas, or the container it
is in, as the same kind of thing. This means: define a class
interface with your GetText and SetText operations, and assign the
class interface to both the container and canvas class. Now, you
can declare a variable to be of the type of the class interface,
and use it to access either.
Though I'm not sure why you'd want to do this.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>