Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Computed Properties and Subclasses (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: binary plist file type
Next thread: Re: realbasic-nug Digest, Vol 17, Issue 142


Win32 API Declares   -   Berg, Heath
  Computed Properties and Subclasses   -   Alberto Paderno
   Re: Computed Properties and Subclasses   -   Mars Saxman
   Re: Computed Properties and Subclasses   -   Phil M
   Re: Computed Properties and Subclasses   -   Mars Saxman
   Re: Computed Properties and Subclasses   -   Björn Eiríksson <b
   Re: Computed Properties and Subclasses   -   Joseph J. Strout
   Re: Computed Properties and Subclasses   -   Mars Saxman
   Re: Computed Properties and Subclasses   -   Karen
   Re: Computed Properties and Subclasses   -   Karen
   Re: Computed Properties and Subclasses   -   Norman Palardy
   Re: Computed Properties and Subclasses   -   William Squires

Computed Properties and Subclasses
Date: 18.08.05 20:46 (Thu, 18 Aug 2005 21:46:52 +0200)
From: Alberto Paderno
Is it permitted for a subclass to redefine a computed property a parent
class defined?

Thanks in Advance.

Re: Computed Properties and Subclasses
Date: 18.08.05 21:17 (Thu, 18 Aug 2005 13:17:03 -0700)
From: Mars Saxman

On Aug 18, 2005, at 12:46 PM, Alberto Paderno wrote:

> Is it permitted for a subclass to redefine a computed property a
> parent class defined?

No, properties are not virtual and thus cannot be overridden.

Mars Saxman
REAL Software
_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 18.08.05 21:20 (Thu, 18 Aug 2005 22:20:32 +0200)
From: Phil M
On Aug 18, 2005, at 10:17 PM, Mars Saxman wrote:

>> Is it permitted for a subclass to redefine a computed property a
>> parent class defined?
>
> No, properties are not virtual and thus cannot be overridden.

But wouldn't a method with the same name over-shadow the property?
That would appear to override the base class.

_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 18.08.05 21:33 (Thu, 18 Aug 2005 13:33:51 -0700)
From: Mars Saxman

On Aug 18, 2005, at 1:20 PM, Phil M wrote:

> On Aug 18, 2005, at 10:17 PM, Mars Saxman wrote:
>
>> No, properties are not virtual and thus cannot be overridden.
>
> But wouldn't a method with the same name over-shadow the property?
> That would appear to override the base class.

Sure, but the key word here is "appear"; the shadowing method will
not actually override the property. It will just muddy the waters,
with an additional declaration similar to the existing one.

Mars Saxman
REAL Software
_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 18.08.05 22:40 (Thu, 18 Aug 2005 21:40:14 +0000)
From: Björn Eiríksson <b
Why exactly are computed properties not virtual ?

I thought they should be equal to so setter getter function pair like
foo() as integer, foo(assigns value as Integer)

I mean why have exceptions in the language instead of having it
clean ? Where clean would mean things are consistent, that is
functions are virtual, and since a computed property is nothing but a
function then it too should be virtual.

Re: Computed Properties and Subclasses
Date: 18.08.05 22:56 (Thu, 18 Aug 2005 15:56:53 -0600)
From: Joseph J. Strout
At 9:40 PM +0000 8/18/05, Björn Eiríksson wrote:

>Why exactly are computed properties not virtual ?

Properties have never been virtual. Not that
that's a complete answer, but see below.

>I thought they should be equal to so setter
>getter function pair like foo() as integer,
>foo(assigns value as Integer)

No, they're equal to normal properties, except
that they can do some computation upon read or
write.

>I mean why have exceptions in the language
>instead of having it clean ? Where clean would
>mean things are consistent, that is functions
>are virtual, and since a computed property is
>nothing but a function then it too should be
>virtual.

It's clean because it's consistent, that is
properties are nonvirtual, and since a computed
property is a property then it too should be
nonvirtual.

Of course if you want something that mostly looks
like a property but whose computations can be
overridden, you can still use a method pair.

Best,
- Joe

--

Re: Computed Properties and Subclasses
Date: 18.08.05 23:03 (Thu, 18 Aug 2005 15:03:29 -0700)
From: Mars Saxman

On Aug 18, 2005, at 2:40 PM, Björn Eiríksson wrote:

> Why exactly are computed properties not virtual ?

Because properties, in general, are not and have never been virtual.

> I thought they should be equal to so setter getter function pair
> like foo() as integer, foo(assigns value as Integer)

Nope. They are properties, with custom accessor routines; it's the
same system plugins and the RB framework have always used.

Mars Saxman
REAL Software
_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 19.08.05 02:47 (Thu, 18 Aug 2005 21:47:43 -0400)
From: Karen

On Aug 18, 2005, at 3:46 PM, Alberto Paderno wrote:

> Is it permitted for a subclass to redefine a computed property a
> parent class defined?
>

Not Really...

BUT a good way to give yourself the flexibility to do the same thing
if you think you might need to without method clutter is to use
events to override default computed property behavior from subclasses
when necessary. One way to do it would be as follows:

Computed Property Foo as Integer
Function Get as Integer
Dim result as integer
If FooHandler(False, Result) then Return result
... ' your default functionality if any
Return result
End Function

Subroutine Set(Value as Integer)
If FooHandler(False, Value) then Return
... ' your default functionality if any
End Subroutine

New Event FooHandler(IsSetting as Boolean, ByRef Result as Integer)
as Boolean

- Karen

_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 19.08.05 02:50 (Thu, 18 Aug 2005 21:50:52 -0400)
From: Karen

On Aug 18, 2005, at 9:47 PM, Karen wrote:

> Subroutine Set(Value as Integer)
> If FooHandler(False, Value) then Return
> ... ' your default functionality if any
> End Subroutine
>

That should be:
If FooHandler(True, Value) then Return

- karen
_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 19.08.05 02:54 (Thu, 18 Aug 2005 19:54:15 -0600)
From: Norman Palardy

On Aug 18, 2005, at 7:47 PM, Karen wrote:

>
> On Aug 18, 2005, at 3:46 PM, Alberto Paderno wrote:
>
>> Is it permitted for a subclass to redefine a computed property a
>> parent class defined?
>>
> Not Really...
>
> BUT a good way to give yourself the flexibility to do the same thing
> if you think you might need to without method clutter is to use events
> to override default computed property behavior from subclasses when
> necessary. One way to do it would be as follows:
>
The other is to just use a get / set pair of methods and avoid the
contortions

_______________________________________________
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>

Re: Computed Properties and Subclasses
Date: 20.08.05 15:01 (Sat, 20 Aug 2005 09:01:09 -0500)
From: William Squires
On Aug 18, 2005, at 3:20 PM, Phil M wrote:

> On Aug 18, 2005, at 10:17 PM, Mars Saxman wrote:
>
>>> Is it permitted for a subclass to redefine a computed property a
>>> parent class defined?
>>
>> No, properties are not virtual and thus cannot be overridden.
>
> But wouldn't a method with the same name over-shadow the property?
> That would appear to override the base class.
>
That's why I prefer to make properties that are in the API of my
class, to be methods; the class hides the actual data storage behind a
Protected/Private scope specifier.
This has the following advantages:

1) Subclasses can override the behavior
2) Access control - I control whether the access is read-only,
write-only, or read-write (or none at all!)
3) It provides a cheapie way to include 'properties' in a class
interface!
4) It's a good place to put sanity checks

It has the following disadvantage:

1) You have to do a bit of coding in the base class, or any class that
inherits this 'property' from an interface. (boo, hoo... I think I'm
gonna cry 'cause it's too hard... ) :) (note the sarcasm here...)

> _______________________________________________
> 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>
A compiler is a tool for turning source code into error messages;
generating machine language bytes is just a fortuitous by-product!

_______________________________________________
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>