2.2.1 Programming Techniques(uncomplete) Flashcards
Name 3 programming constructs
-sequence
-selection
-iteration
which two categories of loop is iteration split into
-count controlled loop
-condition controlled loop
describe how the branching programming construct work
A certain block of code is run if a specific condition is met, using IF statements
what is recursion
a programming construct in which a subroutine calls on itself during its execution until the stopping condition is met
what is the base case in recursion
A condition that must be met in order for the recursion to end
state two advantages of recursion
- can be represented in fewer lines of code
-Easier to express some functions recursively than using iteration
state a disadvantage of recursion
-inefficient use of memory
-danger of stack overflow from it calling itself repeatedly which would cause the call stack to run out of memory this would cause the program to crash
-difficult to trace
give two pieces of information that are stored on the call stack
-parameters
-return addresses
-local variables
define scope
the section of the program in which a variable is accessible
give two advantages of using local variables over global variables
-less memory is used
-self contained so unaffected by code outside of the subroutine
- take procedure over global variables with the same name
what is top down design
A technique used to modularize programs in which the problem is continually broken down into sub problems, until each can be represented as an individual, self-contained module which can preforms a certain tasks
state two advantages of a modular design
-makes a problem easier to understand and approach
-simpler to divide tasks between a team
-easier to manage project
-self contained modules simplify testing and maintenance
-greater reusability
what is the difference between procedures and functions
Functions must always return a value while a procedure does not always have to return a value
what does it mean to pass a parameter to a subroutine by reference
the address in memory of the parameter is passed to the subroutine so its value outside of the subroutine will be updated
state 2 features of an IDE
-stepping
-variable watch
-breakpoint
-source code editors
-debugging tools
what does IDE stand for
integrated development environment
What is a local variable
Local variables have limited scope which means that they can only be accessed within the subroutine in which they were defined.
Therefore, multiple local variables with the same name can exist in different subroutines.
Advantage to local variables
Using local variables is considered to be good programming practice because it ensures subroutines are self-contained, with no danger of variables being affected by code outside of the
suoroutine.
What is a global variable
Global variables, on the other hand, can be accessed across the whole program.
These are useful for values that need to be used by multiple parts of the program
Disadvantage to global variables
using global variables is not recommended because they can be unintentionally overwritten. As global variables are not deleted until the program terminates, they require more memory than local variables which are deleted once the subroutine has been completed.
Modular programming
Modular programming is a technique used to split large, complex programs into smaller, self-contained modules. A modular design also makes it easier to divide tasks between a team and manage projects, whilst simplifying the process of testing and maintenance, as each component can be dealt with individually. This improves the reusability of components, as once a module has been tested, it can be reused
with contidence
What is a parmeter
A parameter is a variable used in a subroutine to receive input data from the calling code
Stepping IDE
This allows you to monitor the effect of each individual line of code by executing a single line at a time
Variable watch IDE
This allows users to observe how the contents of a variable change in real-time
Breakpoint IDE
IDEs allow users to set a point in the program at which the program will stop
Source code editor IDE
The editor provides features such as autocompletion of words, indentation, syntax highlighting and automatic bracket completion.
Debugging tools IDE
Some IDEs also provide run-time detection of errors with a guide as to where in the code they are likely to have occurred.