Global variable alternatives

mpselby

New member
Joined
Oct 28, 2009
Messages
1
Programming Experience
3-5
I have a complex mathematical VB program that is in prototype and I need to consider alternatives to its heavy dependance on global variables before moving to production.

The program depends on two very large (up to 1GB each) global variables (heavily nested UDTs). Each is populated at run time with data from a database before the calculations being. Thereafter, one is a parameter set and is only read and the other holds data and is continuously read and written to thoughout the calculation. The exact dimentions of each are set at run time with ReDims.

A small group of subroutines are recursively called (by themselves) to generate random scenarios. Another group of routines is called by the first group and perform the reading of and writing to the global data variable.

At the end of the calculation the results in the global data variable are summarised and written back to the database.

Every thread I have ever read says to minimise the use of global variables but in this case I have struggled to dream up and alternative. The variables are so large that I am concerned passing them around between procedures in some way will hammer the performance.

Any ideas?
 
Back
Top