2.3
暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。
卡片预览 (17 张)
What types of checks can you do to data input?
• 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?
• More robust • More user-friendly • Prevent further errors from occurring later • Ensures that data entered meets the specific rules
What is defensive design?
• Thinking ahead about the problems that may occur • Nullifying them before they happen
What are examples of defensive design?
Considering: - 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?
• 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?
• No bugs • Has an acceptable performance • Ensure no unauthorised access • Check it meets the requirements
What does iterative testing mean?
• 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?
• Meets all requirements • Testing that all functions work together • Able to produce results with any data
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?
• Anticipate a range of possible outputs • Descriptive and helpful prompts
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
• Use sub programs to separate chunks of code • Use comments to explain sections of code • Use variables to allow different programmers to easily understand the code • Used indentations to see where structures begin and end
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
It returns a value