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
What is final testing for?
To make sure modules work well together
Best way to test
Combination of iterative + final testing
Test Plan
Outlines exactly what the programmer will test and how
Covers all routes through the program
Types of Test Data
- Normal Data - things that the user is likely to input
- Boundary Data - things at the limit of accepted values
- Invalid Data - inputs with correct data type, but rejected
- Erroneous Data - wrong data type, rejected
Syntax Errors
When compiler doesn’t understand it because it doesn’t follow the rules or grammar of the programming language
Logic Errors
When compiler can run the program, but gives an unexpected output