Local variables have limited scope which means that they can only be accessed within the block of code in which they were defined
local variables with the same name can exist in different subroutines and will remain unaffected by each other
g local variables is considered to be good programming practice because it ensures subroutines are self-contained, with no danger of variables being affected by code outside of the subroutine
Global variables, on the other hand, can be accessed across the whole program
global variables is not recommended because they can be unintentionally overwritten and edited
. As global variables are not deleted until the program terminates, they require more memory than local variables which are deleted once the subroutine has been completed
Modular programming is a programming technique used to split large, complex programs into smaller, self-contained modules
A modular design also makes it easier to divide tasks between a team and manage, whilst simplifying the process of testing and maintenance, as each component can be dealt with individually
r technique used to modularise programs is called the top-down approach, in which the problem is continually broken down into sub-problems, until each can be represented as an individual, self-contained blackbox which performs a certain task
Procedures and functions are both named blocks of code that perform a specific task. While pro
While procedures do not have to return a value, functions must always return a value. Procedures can return multiple values whereas a function must return one, single value
Procedures are typically given data as parameters for manipulation while functions commonly make use of local variables
When parameters are passed into a subroutine, they can be passed either by value or by reference
When a parameter is passed by value, it is effectively treated as a local variable; a copy of the value is passed to the subroutine and discarded at the end therefore its value outside of the subroutine will not be affected.
Passing by reference means that the address of the parameter is given to the subroutine, so the value of the parameter will be updated at the given address.
An Integrated Development Environment, or IDE, is a program which provides a set of tools to make it easier for programmers to write, develop and debug code
Debugging tools Some IDEs also provide run-time detection of errors with a guide as to where in the code they are likely to have occurred through line numbers and highlighting.
Breakpoint IDEs allow users to set a point in the program at which the program will stop. This can either be based on a condition or set to occur at a specific line. This can help to pinpoint where an error is occurring
Source code editor The editor aims to make the coding process easier by providing features such as autocompletion of words, indentation, syntax highlighting and automatic bracket completion
Stepping This allows you to monitor the effect of each individual line of code by executing a single line at a time