GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Global and Local Variables

Ariana Parr Computer Science A level Englisch 8 Karten

Karten in diesem Stapel (8)

  1. 1What are the two ways of storing data?Variables and constants
  2. 2What is a variable?A space for a single piece of data that has been reserved in the memory so that it can be accessed and changed later in the code. Therefore it contains data that is changed many times while the code is running
  3. 3What is a constant?A space for a single piece of data that has been reserved in the memory so that it can be accessed later in the code BUT IT CANNOT BE CHANGED
  4. 4What is a local variable?Visible only in a single module where it is created/declared. They are set/declared inside a function or procedure
  5. 5What is a global variable?Visible throughout the program and may be accessed from more than one part of the program. They are set/ declared outside any functions or procedures.
  6. 6Why use global variables?- used where a value needs to be accessible from different parts of a program
    - irrespective of the place it was accessed the value will always be the same
  7. 7Why do programmers prefer not to use global variables?- creates testing problems/ to test code within a function the coder will have to runt he entire code
    - makes it difficult to maintain/ difficult to see where the variables are being updated/ increases chance of error
    - increases coupling which joins several parts of the code together, therefore a change in one module could have an impact on another
  8. 8How do we avoid the problems of global variables?- parameter passing/ keeping it as local in the main code and using a copy of the variable as a parameter by value/ only the copy will be changed
    - setting rules (where will they be defines, how much should variables conform)

Informationen

Beschreibung
A level Computer Science (Unit 2 - Topic 2) Karteikarten am Global and Local Variables, erstellt von Ariana Parr am 20/02/2022.
Erstellt von
Ariana Parr
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck