FACTOID # 171: Want to go to the United States? Try going to Albania first. Albania has more U.S visa lottery winners per capita than anywhere else in the world.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Global variables

In computer programming, a global variable is a variable that does not belong to any subroutine in particular and can therefore can be accessed from any context in a program. They are contrasted with local variables. See also, scope.


They are usually considered bad practice precisely because of their nonlocality: a global variable can potentially be modified from anywhere, and any part of the program may depend on it. A global variable therefore has an unlimited potential for creating mutual dependencies, and adding mutual dependencies increases complexity. See Action at a distance. However, in a few cases, global variables can be suitable for use. They can be used to avoid having to pass frequently-used variables continuously throughout several functions, for example.


Compare this with a constant, which can be seen as a read-only global variable (even though this use of variable is an oxymoron). Because a constant, by virtue of its constancy, can only be "modified" (defined) at one point in the program, all dependencies on a constant are one-way.


  Results from FactBites:
 
Programming Techniques:Global Variables - GPWiki (702 words)
Multiple blocks of code accessing a global variable are dependent on each other (because of their mutual dependence on the variable), yet the relationship between them is indirect and even further-removed.
In addition, the state of an object dependent on a global variable is dependent on the state of the global variable, which is not under its control.
Removing the ability to access the internal state of a global variable does not make it less global, but it does reduce the coupling, and it also reduces the coupling between separate blocks of code that are dependent on the global variable.
Global variable - Wikipedia, the free encyclopedia (192 words)
In computer programming, a global variable is a variable that does not belong to any subroutine in particular and can therefore can be accessed from any context in a program.
They are usually considered bad practice precisely because of their nonlocality: a global variable can potentially be modified from anywhere, and any part of the program may depend on it.
Compare this with a constant, which can be seen as a read-only global variable (even though this use of variable is an oxymoron).
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m