Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OverRiding SubClasses at RunTime
Message
From
04/05/1998 20:07:34
 
 
To
04/05/1998 18:10:45
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00096608
Message ID:
00096912
Views:
22
>A final recommendation concerns "oPreference", as we've so far put it. It would be best if the preference engine were abstracted, and certainly it'd be best if the preference engine wasn't hanging off a global.
>
>So how aboy this instead:
>
>*-- Form Init()
>IF TYPE( "THIS.oPrefernce.BaseClass")= "C"
>  FOR EACH oControl in THIS.Controls
>    THIS.oPreference.Execute( oControl)
>  ENDFOR
>ENDIF
>
>Now this makes the form class more reusable. Of course, now we need to make the connection between THIS.oPreference and the preference engine itself, which could also be handled in the Init(), but also consider making that an external process. If you do it in the init(), then the usual way to do that is use a cPreferenceEngine property in an expression like
>
>*-- Earlier in the form Init()
>IF !EMPTY( THIS.cPrefernceEngine)
>  THIS.oPreference= CREATE( THIS.cPrefernceEngine)
>ENDIF
>
>Just kick me if you're there already <s>.

No kicking required. You are building relationships with pieces that I haven’t played with. I’m still a procedural guy that’s making the transition.

I had a little trouble with the stuff above, so I have put down my understanding of what you have suggested below to help me see if I’ve got the idea:

In IF !EMPTY( THIS.cPrefernceEngine):
1) CREATE is really CREATEOBJECT, 2) THIS.cPrefernceEngine is where I put my class’s name that holds the code that will be used to build our “oPreference” object. 3) I “quote” oPreference because that’s not it’s name any more, its now addressable only as THIS.oPreference. 4) Forms that don’t need the services of oPreference can just leave THIS.cPrefernceEngine blank and it won’t be instantiated for that form.

The IF TYPE( “THIS.oPreference.BaseClass”)=“C” is just a check to see if THIS.oPreference exists ... could we have used IF TYPE( “THIS.oPreference”)=“O” instead?

Now my concern is that with n forms open, I’m going to have n copies of my oPreference object in memory. This doesn’t have to be a problem, but perhaps this is why you suggested building the oPreference object in an external process (giving only 1 copy of the object).

I know that the complexity that I see is really a colection of individually understandable pieces. Comments on any concepts that I’ve gone astray with would be appreciated.

Bob
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform