Application v. Local

B

Bryan Harrington

Hello.. I have an asp classic app that I'm using a "common" file that is
included in all pages that contains items like the database connection
string, some common functions etc.

Also included in the file set as local variables are things like

Product Name
Customer Name
Start of Fiscal Year
password min/max length etc..

So.. my question is.. does it make more sense, or is it faster, or better
memory wise to change the local variables to Application variables?

TIA
 
M

Michael D. Kersey

Bryan said:
Hello.. I have an asp classic app that I'm using a "common" file that is
included in all pages that contains items like the database connection
string, some common functions etc.
Also included in the file set as local variables are things like
Product Name
Customer Name
Start of Fiscal Year
password min/max length etc..
So.. my question is.. does it make more sense, or is it faster, or better
memory wise to change the local variables to Application variables?

Using local variables is faster, since they are compiled into the ASP
bytecode. In contrast, Application variables always involve a hashed
lookup: the key, a string value, must be hashed and that result used to
lookup a value in a table. So Application variables will be at least an
order of magnitude slower.

Separate memory is required to store each of these values in each
script's bytecode, but IMO this is insufficient justification for
changing to Application variables.

From your description you are defining mostly constants - values that
do not change during execution. Your scheme is a good one for defining
constants and to some degree protects your variables from being
inadvertently overwritten.

Application variables are truly global in scope and much has been
written about the dangers of global variables. The most common problem
is that a global variable's value is inadvertently overwritten in one
script resulting in an error in another script. Such errors can be
difficult to find.

Good Luck,
Michael D. Kersey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top