Computational Constructs Flashcards
How is code modularity improved?
Keeping sub-programs as self contained as possible so they can be tested independently
What is the scope of a variable?
the part / parts of the program where a variable can be used - eg local variables only exist within the sub program they are defined inside
Why are global variables best avoided when possible?
They have global scope so can be accessed anywhere throughout the program. So their values can be altered unintentionally to bad effect
What are sub-programs defined and called with?
Defined with formal parameters
Called with actual parameters
What is a computational construct?
A combination of control structures which can be used to make solving programming programs more intuitive
The scope of a variable describes…
Where it can be accessed from
What is meant by variable declaration?
When a variable is created in a program
What is a user defined function?
A sub-program written by the programmer which returns a value
What is a method in an object-oriented language?
A function which is defined inside a class and can only be used in relation to an object of that class
Parameters can be passed by….name and define both terms
Value: Parameters which are not changed when passed into a procedure (a local copy of the actual parameter is made and used inside the subroutine)
Reference: Parameters which may be changed by the procedure they are passed into
What is unique about a sequential file compared to other input and output devices?
Treated in the same way but they have specific commands for opening and closing
Function use
A category of sub program which will always return a single value to another part of the program
Scope of a local variable
The sub program where it has been created
Where are actual parameters listed?
On the call line used to activate a sub program
Why is it unnecessary to use the same identifier (name) for related actual and formal parameters?
Most software development environments link parameters based on the order in which they are listed rather than their names
Allows for procedures/functions to be called several times with different values being passed in on each occasion