Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desiging large programs - where to store global vars?

Status
Not open for further replies.

whodaman

Programmer
May 23, 2001
60
CA
Hi all,

I am desiging an ecosystem modeling software. There is an enormous list of global variables that is shared/used throughout the program. I know from good programming techniques, the exe should contain almost nothing, which should house the user controls that call the main computational controls like this:
image006.gif



My question is, where are all the global variables stored? Is it stored in the xocmayaengine.dll? For exaple Microsoft Word, there has to be a global variable what stores all the text in the docuemnt, and other dll's that use the global variable i.e. spell checker. My question is how is this stored?

If anyone could point me to a good link, or brefiely describe this to me, it would be a great help.

Cheers
 
I highly doubt that there's a global variable for a document's text. There is probably a class for each document, and the document has a member variable with the text. That's how you should do it too if at all possible - use a class and just create a single object of it, or create static member variables.
 
Minimize (if possibly avoid) using (at least direct access to) of globals at all. Pass pointers or references via parameters. Collect (group) common use variables in proper classes, instantiate (may be unique, as in timmay314's advice) objects. Design and define proper (not fat!) interfaces for your classes (for example, incapsulate DLL references in proxy classes) with minimal (essential only)dependencies...
Global variables are harm. It's possible to designe large (all) projects without any global variables. In our recent project was more than 300000 source lines and no (zero;) global variables...
 
>There is an enormous list of global variables that is shared/used throughout the program

Then I'd say you have a major design problem.

>For exaple Microsoft Word, there has to be a global variable what stores all the text in the docuemnt,

No.

>and other dll's that use the global variable i.e. spell checker. My question is how is this stored?

As members of some class perhaps. Or it gets passed as a parameter (possibly by reference).

In windows programming there is usually only need for one (1) global variable the var holding the application/module/control instance. And that var can usually be ignored as well (it does some initializing and cleanup, but with proper design you can avoid having to call it externally).

/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top