SHARED Variables ..

rzr

Member
Hello All,

One of the legacy application I am working on use's ton's of shared variables..infact looks like everything in the app is shared, from variables to temp-tables.. ( and work tables too !!)

I'd like to move away from the concept of using shared vairables.. but it looks like too much effort having to re-write all those progress files ( & that too when my client doest want to pay for this change.... they are least bothered :) ).

Is there any "easier" way out ?
 

Elod

New Member
There is no easy way out period!

If you have 10.1C or above you can:
- try logical grouping of variables into objects (static members), and share them among the application (bulk replace variable with object:variable)
- skip Temp-tables since you don't want to refactor everything or you can encapsulate it in an object and write get-ers and set-ers for it
- safely replace work-tables with temp-tables since they are deprecated.

Working and proven by an enterprise application.
 

Marian EDU

Member
while static objects could be a quick fix I'll stay away of that route because you gain nothing, as this is not going to help you solve the encapsulation, and even worse you'll get all those 'shared' objects loaded for good... as it is now a shared object is taken out when it goes out of scope, with a static object you simply can't 'unload' it.

if there is no re-write planed (even step by step) then why bother? you might try to apply changes 'as you go' if the product is in maintenance, then see if it's possible to pass those objects around as parameters instead of define them as shared but there sure isn't an easy way out :(
 

tamhas

ProgressTalk.com Sponsor
Depending on the use, there certainly are some fairly easy steps to take for local fixes.

My guess is that you can divide the shared variable use into two or three aspects:
1. Context values like current fiscal period which are set by the menu system and used everywhere.
2. Function specific values which are used widely within one function and not used elsewhere.
3. Linkage specific values which are used to pass from one program to another, but not beyond that scope.

The fix for the last group is simply to convert to using parameters. It is generally pretty trivial to make that switch since you just alter the definition on each side from shared and add the parameter to the run.

For the first group, create a persistent super procedure that has all the values and run it from the menu. Then, when you work on any other code, rip out the shared variables and replace them with local variables ... only those which are actually referenced in the program ... and calls to the super procedure to set the values. For each instance, that is a very small amount of work and you will very gradually improve the code of the system.

For the second group, proceed as for the first, but just when you need to do some work on that function and go systematically through the programs in that function to clean up. That can be a bit more work if it is a function with a lot of programs, but it is quick work.

Now, if you want to do the whole thing, check out http://cintegrity.com/content/Request-Expression-Interest
 
Top