As mentioned by Maarten, the Set method is run when you set the
property to a value.
Honestly, I seldom use the Set method, although the Get method has
been useful on occasion. Sometimes I use computed properties when I
need a constant that is an object, since constants can only be a
number, string, boolean or color. If I need an array or dictionary
constant, I'll often use a computed property (named in my constant
naming convention), using only the Get method. For instance, one
program I'm working on has a Database property of the App object. I
need to refer to this often, but I don't to write App.Database every
time, so i created a computed property, db, which just returns
App.Database. The Set method is not used.
However, I did recently use both the Get and Set methods. Basically,
they were for passthrough properties. The object I was creating had a
property that was another object, which in turn had properties that I
want to access as if they are the properties of the primary object.
So I create computed properties. For Get, I just get the secondary
property's value, and for Set I set the secondary property's value.
Computed properties, if I understand them correctly, are superfluous.
For instance, if you have a property MyProp that is set up as a
computed property (say a boolean property), you could, without
changing the code that accesses the property, rewrite it as methods,
Function MyProp() as Boolean and Sub MyProp(assigns b as Boolean) and
it would act exactly the same way. The function would act like the
Get method and the Sub like the Set method. I suppose having the
computed properties can make things a bit more organized. Instead of
seeing two MyProp methods and having to click on each one to find out
which is the one you want, you have these unambiguously named Get and
Set methods.
Of course, I've only been really using REALbasic for about six
months, so anyone with a better explanation, please enlighten me. :)
Chuck Ross
Developer & Writer
mailto:[EMAIL PROTECTED]
AIM:mer0dyn
web:http://www.chivalrysoftware.com/
_______________________________________________
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>