Defensive design considerations 2 Flashcards
How can a programmer prevent division by zero errors?
Check that a variable is not zero before attempting a division by it e.g
IF num != 0 then
average = total /num
ELSEIF
print(“Error”)
What is a communication error in online systems?
The connection between online systems and host servers is dropped, potentially causing a program to crash or hang when loading / saving data
How should a programmer handle communication errors?
Enable ways for the user to cancel requests or for them to fail gracefully, reporting the connection error
What are common printer errors a programmer should anticipate?
- Printer may run out of paper
- Printer may run out of ink
- Printer may have a jam
How should a programmer handle printer errors?
The programmer should not assume that an output to a printer was successful and should always have options to reprint reports or receipts
What are common disk errors a programmer should handle?
- The file / folder not being found
- The disk being out of space
- The data in the file being corrupt
- The end of the file being reached
How can a programmer make a program robust against disk errors?
Having the program checking files and data before attempting to use them for further processing
What is authentication in programming?
Ensuring data used by systems is secure
What are common methods to secure data in systems?
- Username and password to access systems
- Recovering a password requiring clicking on a link within the email that is sent to the registered address
- Encryption of data files.
How can programmers protect against online bots submitting data automatically?
Using software such as reCAPTCHA that verifies the user is human
What is SQL injection?
SQL injection is a hacking method where malicious SQL code is inserted into input fields. Programmers can prevent it by sanitizing inputs.