2.3 Producing robust programs Flashcards
Defensive design
Thinking about problems that could potentially occur and preventing them before they happen
-anticipating misuse - thinking about ways users could cause program to fail accidentally or deliberately
-authentication - process of establishing user’s identity (username/ password, biometrics)
Input validation
Process of checking data when it is entered to see if it conforms to a rule
-data verification - process of ensuring the user types what they intended (entering email address twice)
-input sanitization - checks and modifies any input before passing it on to the next process (changing the case)
Maintainability
Make program straightforward to understand and modify
-indent program structures in the code
-add comments
-use meaningful variable names
-use subprograms
-whitespace - make code easier to read
Purpose of testing
Ensure program functions as expected
-iterative: testing during program development (each module works)
-final/ terminal: testing after program is finished (make sure all assembled parts of the program work together)
Syntax error
When rules of the programming language are broken
-variables are not declared, incompatibility of data types, keywords misspelt
Logic error
The program runs but does not give expected output
-Conditions and arithmetic operations are wrong
Test data types
Normal inputs - Data which should be accepted by a program without causing errors
Boundary inputs - Data of the correct type which is on the edge of accepted validation boundaries.
Invalid inputs - Data of the correct type but outside accepted validation checks
Erroneous inputs - Data of the incorrect type which should be rejected by a computer system
Refining algorithms
Improve the code
-fix the problem
-make code more efficient or maintainable