Programming Techniques- S11 Flashcards
Algorithm
is a set of rules or a sequence of steps specifying how to solve a problem.
Pseudocode
tool for developing algorithms, and is between English and program statements.
Indentation
Statements shifted to the right that are contained within a block
Initialisation
setting variables to appropriate values at the beginning of a program to ensure there is not a value already assigned to it.
Variables
A name in memory used to store a value with can change during execution.
Constant Variables
a value that cannot be altered by the program during normal execution. E.g pi=3.14159265
Why are Constant Variables used
to make the programs easier to understand, easier to change the value of variable throughout the program and to make sure a programmer doesn’t accidentally change its value.`
Give Data Types
Integer, String, Float, Boolean, Character, Date
Sequences
Two or more statements following each other.
Selection
When there is a condition that needs to be met in order for certain statements to be executed.
Pseudocode for a switch case
switch entry: case “A”: print(“You selected A”) case “B”:1 print(“You selected B”) default: print(“Unrecognised selection”) endswitch
Iteration
An iteration is a repetition so a loop.
Give examples of Iteration
While… End While
For count… Next count
for i… next i
Repeat… until
Subroutines
a named block of code which performs a specific task within the program.
Subroutines are good to use because
Easier to understand Easier to debug Can be reused Each module can be tested independently Work is divided between team, so saves time Each member can work on their expertise
Function
A named subroutine that returns a value, called inline, and performs a specific task.
Procedure
A named subroutine that performs a specific task but does not return a value.
parameter by reference
a parameter can be changed in the subroutine and will then change the value of variable which has been passed in. (only used in procedures)
parameter by value
is when the value is passed to subroutine and is treated as a local variable. Changing the parameter inside the subroutine does not affect the value outside the subroutine.
Global variable
are used in the main program and can be used anywhere in the program including within subroutines.
Local variable
are variables used in a subroutine and are self-contained.
Modular design/programming
When the program is divided into separate self-contained modules or tasks, which can be written and tested individually. Modules can be subdivided further into smaller modules.
Advantages of modular design
Easy to understand Can be reused Reduced development time Modules can be shared between programmers Easier to maintain/debug
IDE (Integrated Development Environment)
A set of tools put all in one program and helps you write code more easily.
Give some examples of what IDE does
debugger, breakpoints, watch, stepper, crash dump, search for functions, compiles, autofils functions
Whats a breakpoint
program stops on that line and you can check the value assigned to a variable
Whats a watch
so value of a variable is displayed when it changes
Whats a stepper
one line is performed at a time.
Whats a crash dump
when the program stops it tells you the data and the state everything is in
Test data
Testing is to try and uncover undetected errors. Test data needs test the outcome for any user input. Stat what test to use, the purpose, the expected result and actual result.
Normal data
data is within the range and is what you would expect would work
Valid data
Input is correct and allowed in the programe
Invalid data
Input is incorrect and not allowed by the computer
Boundary data
data at the ends of the expected range
Erroneous data
just outside the range
Extreme data
Goes way beyond boundary
Logic error
The program compiles but does not give the expected output and does not do what it should.
Syntax error
The code does not follow the rules of the language. The program will not compile or run.
Run time error
When the program doesn’t stop. E.g 0/ a number
BODMAS
an acronym that describes the order priority given to mathematical operations.
Operator Precedence
The default order in which operations in an expression are carried out.
Why is Installation needed
To use camera
Copied onto device so it can be accessed by the OS quicker
To configure initial settings
So the user can access it through an icon (on a phone)
Parameter
An item of data that is passed to a subroutine and used as a variable within the subroutine.