Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: HIDDEN a property is unusable
Message
From
23/02/2005 03:39:30
 
 
To
22/02/2005 19:17:41
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00987841
Message ID:
00989520
Views:
37
Hi Fabio,

I really appreciate your addiction to pure OOP.

Okay, so while VFP lacks the real OOP style it has many advantages for RAD which I wouldn't want to throw away. Some of them are, that you can work both the OOP way and with procedural code.

A workaraound for your problem may be something like this:

The idea is to have an interface class (or bridge pattern) to the real class, exposing only those properties and methods you want to be public. This interface class instanciates the real class wanted as a hidden property and redirects calls to the class. Then you have no need to define a hiddenproperty hidden, simply don't define it in the interface class.
CLEAR
ON ERROR ? MESSAGE()
WITH CREATEOBJECT("Interface","SuperClass")
	.CALL
ENDWITH
? 
WITH CREATEOBJECT("Interface","subClass")
	.CALL
ENDWITH
ON ERROR

DEFINE CLASS Interface as container
    HIDDEN oClass
    
    PROCEDURE Init
       LPARAMETERS tcClass
       
       This.oClass=CREATEOBJECT(tcClass)
    ENDPROC 
    
    PROCEDURE Call 
       RETURN this.oClass.Call()
    ENDPROC 
ENDDEFINE 


DEFINE CLASS SuperClass as Interface
	hiddenproperty = 1
	
	PROCEDURE Init()
	  *
	ENDPROC 

	PROCEDURE call
		? "SuperClass CALL hiddenproperty IS PUBLIC HERE"
		? this.hiddenproperty
        this.hiddenproperty = 3
		? this.hiddenproperty
	ENDPROC 
ENDDEFINE

DEFINE CLASS subClass as SuperClass 
	hiddenproperty = 2	
	* no need for hidden, as the interface is instanciated
	* and the interface doesn't show that property
	* HIDDEN hiddenproperty
ENDDEFINE
Instead of rediricting the call in each method of the interface class , you may use BINDEVENTS in the init of "Interface" to bind all calls of THIS... to THIS.oClass...
And properties of interface should have an assign-method storing their value both in THIS and THIS.oClass.

Bye, Olaf.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform