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
What is passing by value?
when a copy of the value is
passed to a subroutine and discarded at the end. This ensures its value outside of the subroutine remains unaffected.
What is passing by reference?
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.
What is an IDE?
standing for Integrated Development Environment, it is a program which provides a set
of tools to make it easier for programmers to write, develop and debug code.
By what process does a class make an object?
Instantiation
What are some common features of an IDE?
*Stepping
This allows you to monitor the effect of each individual line of code by
executing a single line at a time.
*Variable watch
This allows users to observe how the contents of a variable change in
real-time.
*Breakpoint
IDEs allow users to set a point in the program at which the program will
stop.
*Source code editor
The editor provides features such as autocompletion of words,
indentation, syntax highlighting and automatic bracket completion.
*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.