Component 17 - Key Definitions Flashcards
Programming constructs: sequence, iteration, branching
Sequence – a set of instructions executed in order
Iteration – looping or repeated execution of the same code Branching – use of decisions or IF statements to change the flow of execution depending on the evaluation of a rule
Recursion
The act of a procedure or function calling itself. A seemingly complex concept whereby a problem can be defined in terms of itself. Classic examples include factorial and Fibonacci sequences. Recursive code must have a “base case” which, when hit, will result in the “call stack” unwinding itself, resolving all the previous function calls to produce a final answer
Global and local variables
Global variables are those which are available to any procedure or function, anywhere in code. Generally considered a bad thing as if they are changed unexpectedly somewhere in the code it may not be obvious that this has happened, or where, making debugging and code maintenance difficult.
Local variables only have “scope” in the procedure or function in which they are declared. This means once a procedure or function terminates, these variables no longer exist. They are the preferred method of using variables as it is easy to keep track of where a variable exists/belongs and how it is being accessed
parameter passing by value and by reference
Functions and procedures rely on data being sent to them as inputs. These inputs are called parameters and take the form of variables that are sent to them when called. Parameters may be passed by value – a copy of the variable is sent to the function and discarded after use, or by reference – the variable is sent as a pointer to the data and any changes are persistent
Use of an IDE to develop/debug a program.
IDE’s are a set of tools which allow programmers to edit, create, debug and publish program code. Features usually include a code editor, syntax highlighting, code completion, break points, variable watch, error diagnostics, a translator/interpreter and a compiler.
object oriented techniques
OO is a technique used to write programs which attempt to mimic real life “objects.” Each object is a “class” which is used as a template. When an object is “instantiated” then a copy of the class is created which can be accessed (roughly) like an “intelligent” variable.
A class will specify several methods (things it can do) which are used to perform actions or manipulate the contents of variables. A class will also posses “properties” which are data and variables which describe the object.
OO has the advantage that classes should be completely reusable across different projects and they should be “safe” to use because of “encapsulation” which means variables and data are “private” to a class and can only be accessed or manipulated by calling class methods