On Nov 26, 2008, at 12:47 PM, Norman Palardy wrote:
On 26-Nov-08, at 1:17 PM, Michael Diehr wrote:
Let's say you have an interface, and one of the items in it is
really a property. It seems that a class implementing the
interface can't have a property with the same name as the interface
method (this makes sense, I think). However I'm wondering if
there's a clean way to accomplish this using computed properties,
or 'assigns' or similar? To rephrase my question -- can
Interfaces only describe Methods, or can they describe Properties
as well?
Methods only
They do not specify HOW to implement something just the API that
will be adhered to
A property of any kind is an implementation detail
Ok, that's fair.
Here's my specific problem: I'm trying to create an interface that
is applied to a Window, a plugin class, and a user-defined class.
I'd like the interface to have a "Visible as boolean" getter. It
seems that the Interface won't recognize methods that are inherited
from a superclass (e.g. if I add an interface containing "Visible as
boolean" to a window, I get the "class is missing a method " error.
So, thinking I'd be clever, I just tried to add
function Visible as boolean
return me.visible
to the window.
This of course, doesn't work, as it causes a stack overflow since
"method visible" is shadowing "property visible". I tried "return
super.visible" but that didn't work either (I think because window
classes are not really subclasses?)
I ended up punting and renaming the interface to "IsVisible() as
boolean" along with
function IsVisible as boolean
return me.visible
which works, but seems inelegant.
I'm just wondering if there is a more elegant way to handle this :
How best to add an interface to an object if the interface method name
conflicts with a property of the class?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|