SLR 23/ Programming Techniques Flashcards
Define Global Variables
Global variables are declared outside any procedure or function and can be accessed by any routine in the program.
Define Local Variables
Local variables are declared inside a procedure or function and can only be used inside that routine. It is possible to have local variables with the same name in different routines – they are not seen as the same variable in memory.
Define the Scope
The scope of a variable refers to where it is accessible in the code. The scope is global or local.
Factors of Global Variables
Global variables are kept in memory for the entire time the program is executing – this means the program is not using memory dynamically and is possibly using more memory than it needs.
Factors of Local Variables
Local variables make it easier for different programmers to work on the same program, as their procedures will not conflict if they use same-named variables. This makes it easier to copy code from one program to another.
Define the factors of Procedures (Subroutines)
Used to break a program down into manageable sections.
Makes the program easier to read and debug.
Facilitates use of local variables.
Enables different programmers to work on different parts of the code.
Allows routines to be reused in other programs.
Define the factors of Functions
small routines that perform operations on input data (parameters) and return a result.
Can be called as often as needed, reducing the need for duplicated code.
Building blocks that enable larger programs to be written using reusable code routines.