2.3 Producing Robust Programs COMPLETE Flashcards
What is a check digit?
The last one or two digits in a code are used to check the other digits are correct
E.g. bar code readers in supermarkets use check digits.
What is a format check?
Checks that the data is the correct format.
E.g. National Insurance Number in the form LL 99 99 99 L where L is any letter and 9 is any number.
What is a length check?
Checks that the data isn’t too short or too long.
E.g. a password needs to be more than 8 characters.
What is a lookup table?
Looks up acceptable values in a table.
E.g. there are only 7 possible days of the week.
What is a presence check?
Checks that data has been entered into a field.
E.g. in most databases, a key field card can’t be left blank.
What is a range check?
Checks that a value falls within a specific range.
E.g. number of hours worked (h):
0 < h < 50
What is a spell check?
Looks up words in a dictionary.
E.g. Microsoft Word underlines incorrectly spelled words in red.
Define authentication
A coding method to check that a user is who they say they are and allowed to accesses the program.
The program checks a huge table and reports back to see if the information matches up, if it does then the access is granted
E.g.biometrics, key cards or email.
Define input sanitisation
Ensures that the input is correct and contains only the permitted characters letters and symbols.
E.g. Dave not Dav%e so the % would be removed.
Define maintainability
If a program is to be defensive against attacks, then it has to be maintained and up to date.
Informs the reader of a bug or issues.
Explains the code and its function in more detail.
Stop a line of section of code from executing.
E.g. comments and indentation/spacing.
Define misuse
Maybe in the form of a brute force attack on the program.
Unauthorised acts with intent to impair the operation of the computer.
Define iterative testing
Testing the code as you create it.
E.g. line by line or a section at a time.
Define final testing
Carried out at the end of the program when it has been written.
Define syntax errors
Mistakes in the formatting (the way in which the code is written).
E.g. SPAG mistakes or unneeded capital letters.
Define logic errors
A bug in a program that causes it to operate incorrectly, but not to terminate or crash (not as intended).
Define validation
A check made by a computer to ensure that the data entered is sensible or reasonable and within certain limits and rules.
What should you consider in defensive design?
When data is entered into a program, it’s important that it’s valid, in order for the program to work correctly.
When are runtime errors detected?
Errors which may cause program errors or the computer to crash, even if there appears to be nothing wrong with the program.
E.g. running out of memory.
Computer programs should/shouldn’t be designed to ensure that they can cope with unexpected or erroneous input from users
should
True/False: Defensive design ensures that there are no errors or bugs
False, the number of errors or bugs is minimised
True/False: Defensive design ensures that the program behaves as expected in spite of unexpected user actions
True
True/False: Defensive design ensures that all possible errors that could occur are identified and allowed for
True
Computer scientists should/shouldn’t plan for all contingencies that might occur
Should. These include accidental or deliberate erroneous inputs or item selections
______________ is the process of determining the identity of a user
Authentication
What is authentication usually based on?
A username and an associated password
What does authentication do with a username and password?
Checks that the username and password exist
Why does entering a correct username and password combination not prove that the person inputting them is the person whom they were issued?
It may be identity theft
What is the data validation process?
A process that checks that data that is input is sensible, reasonable and appropriate to be processed by the program.
Why should data validation checks be used?
To ensure that required data is actually input and is within a certain range or of a required length
Give 3 common data validation checks
Any 3 from presence check, length check, range check, type check and format check
What does a presence check ensure?
That data has been entered
What does a range check ensure?
That an input falls within a required range
What does a length check ensure?
That a specified number of characters have been entered
What does a format check ensure?
That data is entered in the correct format, such as entering a date in the format DD/MM/YY
What does a type check ensure?
That the data type of the input is of the specified data type, for example that an integer is entered when specifying a quantity
What does testing of software ensure?
That the software produces the expected results and meets the needs of the users
All software should be tested to ensure that it is ______ so it produces the expected results and can withstand malicious users.
Robust
Testing should be ___________ and should try to find errors rather than just proving that a program works
destructive
When are iterative tests carried out?
As the software is being developed
What is iterative testing?
When tests are carried out on each module and the results are used to inform further development
When is terminal testing carried out?
Once the software has been developed
What is another name for terminal testing?
Final testing
What is the first stage of terminal testing?
Alpha testing
What is the second stage of terminal testing?
Beta testing
Who is alpha testing done by?
Developers
Who is beta testing done by?
Potential users of software
Why should suitable test data be used?
To test the software in all situations
Normal data tests the software under…
Normal working conditions
Boundary data tests the software under…
Extreme conditions (e.g. it will test that length and range checks are functioning correctly)
Erroneous data tests how the software deals with…
Incorrect inputs that may be entered deliberately or by mistake
What should programs have in place to deal with erroneous data inputs?
Routines to deal with them and inform the user that the data is, for example, outside an expected range or numbers are entered instead of text
What are syntax errors?
Grammatical mistakes in code, which could be caused by a misspelling (prnit instead of print) or by missing colons, semi-colons or brackets
Is a missing semi-colon a syntax error?
Yes
Is spelling the word print: “prnit” in code a syntax error?
Yes
What do syntax errors do to a program?
Prevent a program from running
Syntax errors are difficult/easy to spot
Difficult
How can syntax errors be prevented?
By using an IDE
What does IDE stand for?
Integrated Development Environment
What do logic errors cause?
Unintended output because of a fault in the logic of the algorithm (e.g. using the AND operator instead of the OR operator, or a loop that may run forever)
Is a loop that may run forever a syntax error?
No, it is a logic error
Is using an AND operator instead of an OR operator a syntax error or a logic error?
Logic
What are used to help identify logic errors?
Trace tables
Program code should be easy to follow and understand in case…
Changes have to be made or errors corrected
Why should explanations be added to code?
To explain the code and make it easier to understand
How are comments added to code?
Two forward slashes (//) or a hashtag (#)
All code that depends on a previous statement should be ________
Indented
Why should meaningful identifiers be used in code?
So it is easier to follow and understand the program