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

    This week learning assignment is based on Unit 8 Chapter 6 reading of the textbook about the elements of a computing system that focus on the selections relevant for supporting programs with symbols.…

    • 288 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    This paper will describe the variable naming rules of three different programming languages. These three languages are Visual Basic, Python, and Java. Each of these languages has different rules that apply to them and some similarities. I will describe the rules and the similarities and differences in the next few paragraphs.…

    • 878 Words
    • 4 Pages
    Good Essays
  • Better Essays

    Venit, S., & Drake, E. (2011). Prelude to Programming Concepts and Design (5th ed.). Boston, MA: Addison-Wesley.…

    • 1800 Words
    • 6 Pages
    Better 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
  • 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
  • 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

    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
  • 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
  • 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
  • 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
  • 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