2.2.1 Programming techniques- Callum Flashcards
What does sequence mean as a programming construct?
Code is executed line-by-line, top to bottom
What is selection?
when a certain block of code is run ONLY if certain conditions are met
what is iteration?
A block of code is repeated a certain number of times or until a condition is met
What loops are examples of iteration?
For, While, Repeat until
What is recursion?
A programming construct in which a subroutine calls itself over and over until a stopping condition is met.
What is an advantage of recursion?
Solutions can be represented in fewer lines of code that with iteration.
What are the downsides of recursion?
it has very inefficient memory usage due to creating copies of variables.
Recursion is also quite difficult to trace.
what is a local variable?
A variable that is accessible only in the subroutine in which it is defined.
Why is using local variables good programming practice?
It eliminates the danger of variables being affected by code outside of the subroutine.
What is a global variable?
A variable that is accessible throughout the whole program.
Why is using global variables not recommended in large programs?
They can be unintentionally altered by parts of the program.
They also take up more space in memory than local variables as they are not deleted after a subroutine is finished.
what is modular programming?
Modular programming is a technique used to split large, complex programs into
smaller, self-contained modules.
What are some advantages of modular programming?
makes it easier to split tasks between a team and manage projects.
simplifies the process of testing, as each component can be dealt with individually
improves the reusability of components
what is top-down design?
when a problem is continually broken down into sub-problems, until each can be represented as an individual, self-contained module which performs a certain task
What is another word for module in programming?
subroutine