Making more robust and maintainable programs Flashcards
what are 2 defensive design methods?
data validation
anticipating misuse
verification
what is data validation?
checking that user input meets certain criteria before processing it
what are the 5 data validation checks and an example?
type check - strings, int
range check - 1 to 10
presence check- required fields
format check - dd/mm/yyyy
length check - longer than 10 characters
what are the 3 benefits of data validation?
- more robust
- more user friendly
- prevent further errors in the algorithms
what are 4 examples of anticipating misuse and a way to prevent each?
dividing by zero - check before calculations if variables are zero
communication error - failing to connect to a server, having a cancel request button
printer/peripheral error - always have a reprint option
disk errors - checking files and data before using them for processing
give 3 ways to make a program for verified
username and password
password recovery
encryption
Captcha
defend against SQL injections
why is keeping a program maintainable important
so that it can be understood and edited quickly by you or others
what are 4 methods to maintain a program?
use comments - to explain or section out pieces of code
leave gaps - to make it easier to read and more organised
use indentation - for increased readability
use descriptive variables - so it is easier to tell what they do
use functions - to structure code
use constants