6/9/24

Cards (26)

  • What are the defensive design considerations mentioned in the study material?

    Input validation, anticipating misuse, and authentication
  • What are the key aspects of making maintainable programs?
    • Use of sub programs
    • Naming conventions
    • Indentation
    • Commenting
  • Why is input validation important in programming?
    It ensures that no errors occur as a result of incorrect user input
  • What happens if a user enters a string when asked for their age in the program?
    The program will crash because it tries to perform a calculation with a string
  • What is the purpose of data validation routines?
    To ensure that data entered is of the right type, such as an integer
  • What limitations does validation have regarding user input?
    Validation cannot ensure that the user has not entered a wrong value or made a spelling mistake
  • What are the types of validation checks that can be applied to user input?
    • Range check: Ensures a number or date is within a sensible range
    • Type check: Ensures data is of the right type
    • Length check: Ensures text is not too long or too short
    • Presence check: Ensures data has been entered
    • Format check: Ensures the format of data (e.g., postcode, email) is correct
  • What validation check is performed in the given algorithm for postcode?
    It checks if the postcode length is between 6 and 8 characters
  • How can you rewrite the algorithm to keep asking for a valid postcode?
    Use a WHILE loop to repeatedly ask for input until the postcode is valid
  • What is the difference between validation and verification?
    Validation checks if data is reasonable, while verification double-checks that data has been entered correctly
  • What is double-entry verification?
    It requires the user to enter data twice to ensure accuracy
  • What tasks should be performed in the algorithm for age validation?
    1. Ask the user to enter their age
    2. Call a function called rangeCheck with age, lower limit, and upper limit as parameters
    3. Validate the entry to ensure it is between 16 and 19
    4. Output "Age valid" or "Age invalid" based on the validation result
  • What statements are needed to validate quantity and price using the rangeCheck subroutine?
    rangeCheck(quantity, 1, 100) and rangeCheck(price, 10.00, 150.00)
  • What is the purpose of authentication routines?

    To ensure a person is who they claim to be
  • What is a common method of online authentication?
    Entering a password
  • Why are users often limited to a finite number of password attempts?
    To prevent brute-force attacks by hackers
  • What is a brute-force attack?

    A method where software tries every combination of letters, numbers, and special characters
  • How can you make a password more difficult to hack?
    Use a password of 8 characters or more
  • What are the key aspects of maintainable programs?
    • Programs need to be maintained for improvements, bug fixes, or new features
    • Written in a way to make them easily maintainable
    • Includes the use of sub programs, naming conventions, indentation, and commenting
  • Why is it important to use meaningful names for variables and functions?

    It makes code easier to read and understand
  • What are the benefits of using sub programs?
    • They allow for reusable code
    • Bugs can be fixed easily
    • They can take inputs and return values
  • How does indentation improve code readability?
    It helps to easily see which lines of code are part of different structures
  • Why may indentation be essential in some programming languages?
    Some languages use indentation to define where structures start and end
  • What are the typical uses of comments in code?
    • To explain difficult parts of a program
    • At the start of a function to explain its purpose
    • Not used for obvious parts of code or syntax explanations
  • What happens if you enter the wrong password during authentication?

    An error message is displayed if the user ID cannot be found
  • How do the concepts of input validation, anticipating misuse, and authentication improve program design?
    • Input validation checks that input meets certain rules
    • Anticipating misuse prevents too many password entries to deter hackers
    • Authentication ensures data is entered correctly or checked from an alternative source