2.3 Robust Programming Flashcards
Defensive Design Considerations
- Authentication
- Anticipating misuse
Authentication
Verifying the identity of a user.
Examples of Authentication
Username, password or biometrics
Anticipating Misuse
Designing a program in a way that is resilient to potential misuse.
Types of Anticipating Misuse
- Division by 0
- Communication error
Validation
Checking input data is sensible and in the right format.
Types of Input Validation
-Type check
- Range check
- Presence check
- Format check
- Length check
Type Check
Is the input the correct data type?
E.g. Inputting an integer where it asks for a name.
Range Check
Is the input within range?
E.g. Inputting 1000 where it asks for age
Presence Check
Has required data been entered?
E.g. Mandatory questions on google form
Format Check
Correct format?
E.g. DD/MM/YYYY
Length Check
Does the input have the correct number of characters?
E.g. 8 character password
Advantages of Input Validation
- Make a program more robust
- More user friendly
- Prevents further errors later on
Maintainability
The process of ensuring that a program is easy to understand, modify and update.
Maintainability Techniques
- Use of subprograms
- White space
- Indentation
- Relevant variable names
- Comments
Use of subprograms
They give the code structure and make the purpose of the code clear.
White space
Separates sections of code to make them visually clearer.
Indentation
Makes it clear which lines of code are part of iteration statements.
Relevant variable names
Appropriate variable names mean that understanding the purpose of the variable will be easier.
Comments
Provide information about what the different parts of the program do.
Purpose of Testing
To remove bugs and to ensure that the program functions as intended.
Types of Testing
- Iterative testing
- Terminal testing
Iterative Testing
Carried out while a program is being developed. The programmer writes a section of code (module) then tests it.
Terminal / Final Testing
Carried out after all the modules are complete to ensure the code functions as it should.
Syntax Error
Errors which break the grammatical rules of the programming language and stop it from being run.
Logic Error
Errors which produce unexpected output.
Normal Test Data
Sensible, possible data that a program should accept and be able to process.
Boundary Test Data
Valid data that falls at the boundary of any possible ranges.
Erroneous Test Data
Data that a program cannot process and should not accept.