Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Public vs Private Datasession
Message
From
14/12/2000 18:46:30
 
 
To
14/12/2000 11:16:24
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00453417
Message ID:
00453685
Views:
17
>I am sure this has been asked before but I missed it so I am asking again.
>
>I am not clear on how data is handled when using Private vs Public data sessions.
>
>Where can I get a clear explanation.
>
>In particular what are the side affects of changing a forms datasession from public to private. The application does
>use a few global variables, but the are thinks like userid, timeout for message boxes, etc (around 5 or 6).
>
>The forms are in two broad catagories:
>
>1. front end for reports where datasession is in the form not the report.
>
>2. data entery forms which may call other forms.
>
>The application was rewritten in VFP 5 (orignal was FPW 2.6)
>
>It needs to be moved to VFP 6 and eventually 7.

I avoid public variables in general, as well as using the default public datasession. As others have pointed out, PUBLICs break encapsulation and expose themselves to side-effects from assignment operations; rather than limiting the effect of a change to the scope of the procedure or object as would be the case with LOCALs and member properties respectively, the scope of alteration to a PUBLIC will apply to the entire app for the life of the variable. In nearly all cases, using a PRIVATE scoping at a high enough level in the code can be substituted for PUBLICs, and I prefer to use pass by reference or pass through an object to the downward inheritance of PRIVATE scoped objects; most of my PUBLIC or PRIVATE variables are global objects which for some reason can't be added to an existing global like _SCREEN.

The use of the default datasession opens you up to all the standard side effects of unrestricted opening and closing of tables by several forms; I generally use private datasessions which may then spawn child forms with public datasessions that share their parent's private datasession, but I'm careful to make certain that the tables are not auto-closed.

>
>Any pointer appreciated.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform