2.3 Producing robust programs Flashcards
what are the defensive design considerations
- anticipating misuse
- authentication
one method of authentication
usernames and passwords can be entered. if they match previously stored entries for that user then access is granted
what is anticipating misuse
trying to predict all possible inputs so that it will never crash or give an incorrect result
when validation or verification can’t solve the issue, help messages and careful instruction should be used
what is authentication
making sure that a person is who they say they are
methods include usernames and passwords, fingerprint ID or facial recognition
what is input validation
the checking of input data to ensure that it is sensible or reasonable. it cannot guarantee that the data is correct
types of input validation
- range check
- length check
- type check
- presence check
- format check
what is a range check
the input is within a specified range
what is a type check
the input is the right data type
eg string, integer
what things are important to the maintainability of a program
- use of sub programs
- naming conventions
- indentation
- commenting
what is verification
the input of data twice to see if they match
advantages of subprograms
- makes debugging the program easier as they are usually quite short
- they can be tested separately
- a particular subprogram can be called multiple times in the same program and be saved in a library to be used again in other programs
- helps to produce structured code
example of decomposition in programming
using subprograms
why do we use naming conventions and what does it involve
helps to identify variable names within a code
helps with readability
- having meaningful and consistent format for the naming of variables
eg camelCase
why do we use indentation
helps the readability as it is then clear where statements within an iteration or other construct start and end. for some programming languages its mandatory
why do we use commenting
used to document for yourself and others the purpose of the program and each subprogram. it can also indicate who wrote the program and when it was last updated
helps to ensure that the program can still be understood and maintained long after it was written
the purpose of testing
to ensure that for any input, the program always runs correctly
types of testing
iterative
final or terminal
what is iterative testing
carried out using a pre-written test plan, finding and correcting errors in a program and retesting until all tests give the expected output
done during development
what is final testing
checking that all the required functions have been included, nothing is missing and everything works correctly when data is entered
done when the program is completely finished
what are the two types of errors in programming
syntax
logic
what is a syntax error
errors which break the grammatical rules of the programming languages and stop it from being run
what is a logic error
errors which produce an unexpected output but will still run
what are the types of test data
normal
boundary
invalid/erroneous
what is normal test data
data which should be accepted by a program without causing errors
what is boundary test data
data of the correct type which is on the very edge of being invalid - using both ends of the allowed range
what is invalid test data
data of the correct data type which should be rejected by the computer system
what is erroneous test data
data of the incorrect data type which should be rejected by the computer system