2.3 Producing Robust Programs Flashcards
Defensive Design
- Anticipate how user may misuse program , and prevent it.
- Ensure code is well-maintained
- Testing to reduce errors
Input Validation
Checking if data entered meets a certain criteria before passing into the program
Types of Input Validation
- Range Check - checks data is in specified range
- Presence Check
- Format Check
- Look-up Check - checks the data against a table of accepted values
- Length Check
Defensive Design: Authentication
Confirming the identity of a user before they can access certain parts of the program.
Can do this through passwords
How to increase the security of password - based authentication
Force users to use:
* Strong passwords
* Limit no. of failed attempts
Problem with authentication
If there is too much, the user may not use it.
Factors that affect the maintainability of code
- Commenting
- Indentation
- Variables, sub programs, parameters
Maintainability: Comments
Explain what the key features of the code do, so that different programmers can understand the program
Maintainability: Indentation
To seperate different statements in a program
Maintainability: Variables, subprograms, parameters
- Should be named appropriately (what they actually are)
- Follow standard naming conventions - must not start with a number or have spaces
Types of Testing
- Iterative
- Final
Iterative Testing
Program is tested during its development
Test a module, fix errors, then move on to next one
Final testing
Program is tested at end of its development
What is iterative testing used for?
To find + fix small errors to prevent larfger errors forming later on
What is final testing for?
To make sure modules work well together