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