Preview

Global Variables

Good Essays
Open Document
Open Document
648 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Global Variables
Global Variables This writing assignment will focus on global variables. A global variable is a variable every module in a program can see, meaning that the entire program is its scope (Gaddis, 2010). There are both advantages and disadvantages to using global variables and it is my intention to explore some of them here, starting with the disadvantages. There seems to be a lot to be said about the disadvantages of using global variables. First and foremost the scope itself can be a disadvantage. Since the scope of a global variable is the entire program, it can be trying for one to figure out what part of a program uses what particular global variable and what exactly will be the effect of changing the value (Kenyon, 2010). This scope also makes it hard to debug a program because any statement within a program can change the value of a global variable. Imagine if a program has thousands of lines of code and you find that the wrong value is beings stored in a global variable. You would have to sift through these thousands of lines of code and find every statement that accessed the variable. Another disadvantage has to do with the ability to reuse modules of programming. If you were to design a module within a program that relied on global variables within that program, you would likely not be able to copy that same module into another program. You would have to redesign the module in such a way that it did not rely on the global variable from the first program. Yet another disadvantage is that the use of global variables in a program can make it hard to understand. Since any statement in a program can modify a global variable, you would have to be aware of every part that accesses the global variable in order to understand one particular part (Gaddis, 2010). Naming issues are one final disadvantage of using global variables. Because of their scope, global variables must each have a unique name. It is possible for a programmer to come back to a


References: Gaddis, T. (2010). Starting Out with Programming Logic & Design (Second Edition ed.). Boston, MA: Pearson Learning Solutions. Kenyon, O. (2010, May 27). Avoiding Global Variables. Retrieved from RevUp: http://newsletters.livecode.com/may/issue93/newsletter3.php

You May Also Find These Documents Helpful

  • Satisfactory Essays

    GLOBAL

    • 298 Words
    • 2 Pages

    ****To factor a polynomial means to write the polynomial as a product of prime polynomials.…

    • 298 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    An introduction to computer programming with an emphasis on problem solving will be presented. Specific topics include:…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Better Essays

    7) Global variables make debugging difficult because any statement in a program can change its value.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Best Essays

    [3] A. Abran and J. W. Moore, Guide to the software engineering body of knowledge: trial version (version 0.95)…

    • 2683 Words
    • 11 Pages
    Best Essays
  • Good Essays

    Global vs Local

    • 2098 Words
    • 9 Pages

    UNILEVER in India – Kwality Wall Hindustan Lever faces successful local competitor • Gujarat Cooperative Milk Marketing Federation (GCMMF): India's largest food products marketing organization. • Two million farmers in the cooperative • Slogan: “A taste of India” • PRICE: 10 rupees (20 cents): 100 milliliter Amul ice cream versus 80 milliliter Hindustan Lever Kwality Wall vanilla ice cream • ADVERTISING COSTS: Amul: 1% of sales versus Hindustan Lever: 10-15% of sales on advertising…

    • 2098 Words
    • 9 Pages
    Good Essays
  • Good Essays

    References: Venit, S., & Drake, E. (2011). Prelude to Programming: Concepts and Design (5th ed.). Retrieved from The University of Phoenix eBook Collection database.…

    • 880 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    A Procedural programming module is function, procedure, subprogram or subroutine within a program designed for a specific purpose and only does that one job (Haas, 2011). For outside programmers looking in these are relatively easy to follow and decipher when looked into. Procedural programming modules are most often written in the order they are intended to be executed with the exception of those called upon again later in the program. Modules of this type are good for reuse in the original program because they were designed for that program, but they are not very good for reuse in other programs without heavy modification because they were designed to do a specific task for a specific program, and that does not leave much room for flexibility. Variables can be declared as local within a module and will be exclusive to that module. There is also the ability to create local variables within a given module but you have to remember to pass the correct data in and out using global variables, and they must be declared properly to work right. Considering the preceding, the use of procedural programming modules is an excellent approach to many programming problems…

    • 729 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Prolog

    • 617 Words
    • 3 Pages

    provided that other predicates are true. example: a :- b, c, d. {a is true if b, c, d are true} a :- b, c, d. b. c. d :- e e. example_01 : Directed Graph :: Rule for “Path of length two”…

    • 617 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    who are planning, designing, developing, revising or implementing a new course that introduces programming concepts…

    • 16837 Words
    • 70 Pages
    Powerful Essays
  • Good Essays

    1.) Deitel, H.M., & Deitel, P.J. (2002). Java: How to program (6th ed.). Upper Saddle River, Nj: Pearson Education.…

    • 382 Words
    • 1 Page
    Good Essays
  • Good Essays

    Global

    • 889 Words
    • 4 Pages

    Today we discover: 1. Why accounting regulation is becoming a bigger issue for business and society. 2. What are ‘Accounting Standards’? 3. What is the ‘conceptual framework’ and what is its purpose? 4. Which entities need to produce GPFRs? 5. What criteria must be met before an item is included on a GPFR?…

    • 889 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Introductions to Prolog

    • 2151 Words
    • 9 Pages

    Created around 1972 by Alain Colmerauer with Philippe Roussel, based on Robert Kowalski’s procedural interpretation of Horn clauses. decidable subset: Datalog, a query and rule language for deductive databases its failure as a mainstream language traditionally due to the following: Prolog usage in Fifth Generation Computer Systems project (FGCS) FCGS was an initiative by Japan’s Ministry of International Trade and Industry, begun in 1982, to create a "fifth generation computer"…

    • 2151 Words
    • 9 Pages
    Good Essays
  • Satisfactory Essays

    Morley, D., & Parker, C. (2009). Understanding Computers Today and Tomorrow(11th ed. Philippines).Singapore: Cengage Learning.…

    • 336 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Global

    • 8391 Words
    • 34 Pages

    The Manager of Tracker Fund of Hong Kong (the “Fund”) is required by the Code on Unit Trusts and…

    • 8391 Words
    • 34 Pages
    Powerful Essays
  • Satisfactory Essays

    Work emplacement

    • 379 Words
    • 2 Pages

    GUJARAT TECHNOLOGICAL UNIVERSITY B.E. SEMESTER : VIII COMPUTER ENGINEERING Subject Name: ARTIFICIAL INTELLIGENCE Sr. No. 1. 2. 3. 4.…

    • 379 Words
    • 2 Pages
    Satisfactory Essays