Global variables - application variables vs include file

Discussion in 'ASP General' started by mark4asp, Sep 3, 2003.

  1. mark4asp

    mark4asp Guest

    What are the best methods for using global constants and variables?

    I've noticed that many people put all global constants in a file and
    include that file on every page. This is the best way of doing it - is
    it not? Once the application has loaded the page it is cached and is
    immediately available for other pages.

    With global variables - the best thing to do would be to use
    application variables - so long as there weren't too many declared.
    Is there another (easy) way of using global variables apart from using
    application variables?
    mark4asp, Sep 3, 2003
    #1
    1. Advertising

  2. mark4asp

    CJM Guest

    Yes, Application variables are a good use for global variables. And yes, too
    many application variable can eventually have an impact on the server, so
    you must be reasonable.

    Things like connection strings, paths and other CONSTANTS are ideal fodder
    for application variables. So are VARIABLES that need to be available to all
    users (ie. across all sessions), eg. a Hit-Count.

    However, I'd query what you mean by 'global variables'. You could be meaning
    a variable that is 'global' for one user/one session. In this case, Session
    variables might be in order.

    To take this argument further, you might choose to avoid session variables
    (because they can have a hit on the server), in which case you can use DBs
    and Querystrings to maintain state.

    I hope this all makes some sense...! lol

    Chris


    "mark4asp" <mark4asp#killspam#@ntlworld.com> wrote in message
    news:...
    > What are the best methods for using global constants and variables?
    >
    > I've noticed that many people put all global constants in a file and
    > include that file on every page. This is the best way of doing it - is
    > it not? Once the application has loaded the page it is cached and is
    > immediately available for other pages.
    >
    > With global variables - the best thing to do would be to use
    > application variables - so long as there weren't too many declared.
    > Is there another (easy) way of using global variables apart from using
    > application variables?
    >
    CJM, Sep 3, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov

    #include "file" -vs- #include <file>

    Victor Bazarov, Mar 5, 2005, in forum: C++
    Replies:
    4
    Views:
    535
    Exits Funnel
    Mar 6, 2005
  2. Replies:
    1
    Views:
    342
    Joseph Paterson
    Dec 7, 2006
  3. PTM
    Replies:
    1
    Views:
    331
    Andy Dingley
    Nov 12, 2007
  4. naveeddil
    Replies:
    0
    Views:
    566
    naveeddil
    Jan 4, 2008
  5. Andreas Bogenberger
    Replies:
    3
    Views:
    906
    Andreas Bogenberger
    Feb 22, 2008
Loading...

Share This Page