Inheritance and Custom Properties

David Bovill david.bovill at gmail.com
Thu Apr 16 08:35:48 EDT 2009


 Agreed it is not real OOP inheritance. But just in case you don't get the
way you use "getprop/setprop" handlers to achieve the same sort of automatic
creation of properties that you refer to I'll give you few examples:

   1. You want to create a form view, in which you place records, and you
   want these records to automatically inherit certain properties relating to
   forms - as a simple example you want each control to automatically have a
   property "record_Value". Solution add getprop/setprops to the stack script
   which check for the type of controla nad return and appropriate value - all
   controls in the stack inherit this property without you having to do
   anything.
   2. You want to create a series of image controls that all inherit some
   basic class of properties relevant to images that are not built in to the
   engine. Old technique create a library that implements these properties for
   any images that has some custom property - say "uImageClass" set to true or
   some specific "class" name. New technique implement a behavior and add the
   library scripts to the behavior - except you don't need to check for a
   custom property - instead you can define a single geptprop/setprop in a
   library - say "setprop image_Class someBoolean" which sets the behavior of
   the target image.

In all these cases the inherited behavior is automatic in the sense you
describe - you just issue one command to add the inherited behavior to a
control.

2009/4/15 Jim Bufalini <jim at visitrieve.com>

> Dear Dick and David,
>
> I don't want to be a stickler here and keep this going on forever, ;-) but
> I
> believe the correct answer to "Are *custom* properties inherited?" Has to
> be
> "no."
>
> While it is 100% true that handlers like setProp can be used by the
> application programmer to review, copy, alter and even deny a change of one
> custom property to others, this is not inheritance. And, of course, you can
> write custom handlers like Dick's. But again, this is not true inheritance.
>
> To me, the definition of "inheritance" is that, on the creation of an
> object, it "automatically" assumes characteristics of another object. Or on
> change of a property of one object, its dependent objects' properties
> "automatically" change. The key here is "automatic," and not that "I can
> program it. ;-)"
>
> So for example, if you check the *Purge stack on close" of a main stack,
> then any existing substacks, or any newly created substacks, will
> "automatically" have this property checked. If you then uncheck this
> property (or set it in code), in either the main stack or any of its
> substacks, all related stacks "automatically" reflect the change and this
> property is unchecked. You don't have to program this. And, in fact, you
> cannot program against this inheritance.
>
> This simply does not "automatically" happen with custom properties. (Now
> please don't point out that if you set the custom properties of a
> templateStack, a newly created stack will have those custom properties. ;-)
>
> Hence, custom properties are not inherited in the traditional sense. ;-)
>
>
> Aloha from Hawaii,
>
> Jim Bufalini
>
> > -----Original Message-----
> > From: use-revolution-bounces at lists.runrev.com [mailto:use-revolution-
> > bounces at lists.runrev.com] On Behalf Of Dick Kriesel
> > Sent: Wednesday, April 15, 2009 7:06 AM
> > To: use-rev
> > Subject: Re: Inheritance and Custom Properties
> >
> > On 4/15/09 4:58 AM, "David Bovill" <david.bovill at gmail.com> wrote:
> >
> > > If you want them "inherited" you need to define a "getprop" handler.
> >
> > You can inherit any custom property even without getprop handlers, by
> > walking through the object's long id until you find a value.
> >
> > Here's a function that does that for any given custom property name,
> > and
> > optionally any given custom property set name as well.
> >
> > If you're interested in a similar function that identifies the object
> > that
> > provided the effective value, let me know.
> >
> > As usual, watch out for line wraps imposed by email.
> >
> > -- Dick
> >
> > <postScript>
> >
> > function effectiveValue pCustomPropertyName,pCustomPropertySetName
> >   put long id of the target into tRevObject
> >   if pCustomPropertySetName is empty then
> >     put "put the" && pCustomPropertyName && "of tRevObject into tValue"
> > into
> > tStatement
> >   else
> >     put "put the" && pCustomPropertySetName & "[" & quote &
> > pCustomPropertyName & quote & "] of tRevObject into tValue" into
> > tStatement
> >   end if
> >   lock messages
> >   repeat until tRevObject is empty
> >     do tStatement
> >     if tValue is empty then
> >       if word 1 of tRevObject is "stack" then
> >         delete word 1 to 3 of tRevObject
> >       else
> >         delete word 1 to 4 of tRevObject
> >       end if
> >     else
> >       exit repeat
> >     end if
> >   end repeat
> >   unlock messages
> >   return tValue
> > end effectiveValue
> >
> > </postScript>
> >
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list