2.2.1) Programming techniques Flashcards
what are the advantages of recursion?
- can be represented if you line code, became a less different to errors
- Elegant and compact
disadvantages of recursion
Inefficient use of memory, danger stack overflow, difficult to trace
What is tail recursion?
A form of recession which is implemented in a more efficient way so less stack space is required
what is a scope?
The section of a code in which a variable is available
What is a local variable?
A variable which can only be accessed within the block of code in which it was defined
Why is using local variables good practice?
Ensure functions are self-contained, no danger variables being affected by code outside subroutine
What is a global variable?
A variable that can be accessed across the whole program. Useful for values that need to be used by multiple parts of the program.
Why aren’t global variables recommended?
They can be overwritten by accident, they take up more memory.
What happens when a parameter is passed by value?
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.
what happens when something is passed by reference?
the address of the parameter is given to the subroutine so the value will be updated to the given address
What is an IDE?
A program which provides a set of tools to make it easier for programmers to write, develop and debug a code.
What are some common features of IDEs?
Stepping, Variable watch, Breakpoint, Source code editor, Debugging tools
What is Stepping?
monitoring the effect of each individual line of code
What is variable watch?
Feature to observe how the contents of a variable can change
What is Breakpoint?
A feature allowing users to set a point in the code where the code will stop
What is a Source code editor?
Usability features like auto completion of words, indentation, syntax highlighting and automatic bracket completion
What are debugging tools?
run time detection of errors that guide to the location of the error
What is a class?