2.3 Flashcards
What types of checks can you do to data input? (5)
- Type check: data type
- Range check: within range
- Presence check: something has been entered
- Format check: correct format
- Length check: min/max
Why are input validation techniques important? (3)
- More robust
- More user-friendly
- Prevent further errors from occurring later
What are the anticipating misuses? (4)
- Division by zero: would crash because computer cannot compute
- Communication error: unable to establish connection, server overloaded, should allow cancel/report
- Printer and peripheral errors: running out of paper/ink, allow reprint
- Disk errors: programs that need files (read/write) must consider the file not being found/out of storage space/corrupt data/end of file reached, and must be checked before further processing
How can data used by systems be secure? (5)
- Username and password (forms of authentication)
- Recover password using email
- Encryption
- reCAPTCHA software
- Awareness of SQL injection and other methods
Why do programs need to be tested? (4)
- No bugs
- Has an acceptable performance
- Ensure no unauthorised access
- Check it meets the requirements
What does iterative testing mean? (3)
- Each function was individually tested as written
- Ensures that it can handle incorrect data
- Checking it does not introduce new errors in code
What does terminal testing mean? (3)
- Meets all requirements
- Testing that all functions work together
- Able to produce results with any data
What is a syntax error? (2)
- Rules of the language are broken
- e.g. variable undeclared, wrong data type, incorrect assignment, mispelling
What is a logic error? (2)
- Produces an unexpected output
- e.g. wrong conditions/arithmetics, incorrect sequence
What is a normal input?
- Accepted without errors
What is a boundary input?
- Correct data type which is on the edge of accepted validation boundaries
What is an invalid input?
- Correct data type but outside accepted validation checks
What is an erroneous input?
- Incorrect data type: rejected
How do you handle inputs to make the program more robust? (2)
- Anticipate a range of possible outputs
- Descriptive and helpful prompts
How do you deal with invalid data?
- While not in range, keep asking for input
How do you deal with erroneous data?
- Try int(input())
- Except wrong data type displays error message
Describe three ways in which a programmer can make their code maintainable PPQ
- Use functions
- Use comments
- Use variables
- Used indentations
State what is meant by ‘input validation’
- Checking that the input has the correct data type and format before using it in the rest of the program
State a feature that shows that something is a function and not a procedure PPQ
It returns a value