SLR 2.3 Producing robust programs Flashcards
Describe three ways in which a programmer can make their code maintainable
- Use of comments to explain sections of code.
- Using indentation to identify program branches and code iterations.
- Using descriptive variable names to make the program easier to understand.
- Use of procedures to make the code easier to read.
- Using whitespace or comment markers to indicate the beginning/end of sections of code.
Explain what is meant by the term iterative testing
- Performed whilst the software is being written.
- Each new module/section of code/procedure/iteration/program branch is checked for functionality/logic errors.
- Checking that the new piece of code has not broken existing code, introducing new errors.
- Checking the program handles erroneous and exceptional situations.
What is a logic error?
An error which is not a syntax error but an error in the program logic (it will run but may error or may simply not do what you wanted / expected)
What is a syntax error?
An error in the syntax, that is to say the structure of the language (e.g. a missing colon ‘:’ or lack of correct indentation, incorrect spelling of key words etc.). Syntax errors will cause interpretted languages such as Python to error and compiled languages such as ‘C’ to fail to compile.
State what is meant by the term, “input sanitisation”
• Removing any white space and turning the input into a format that the program is expecting.
Explain what is meant by the term, “presence check”
Checking that any input is received (not just “” when you hit enter without making another entry)
Explain what is meant by the term, “length check”
Checking the input from the user has the correct number of characters (e.g. password is not 1 character)
Explain what is meant by the term, “range check”
Checking the user input has a value within the expected range (e.g. age is not 3000!)
Explain what is meant by the term, “range check”
Checking the user input is of the correct type (strictly speaking the type is always a string for keyboard input but here we mean can it be converted into the correct type e.g. int(“ten”) would fail but int(“10”) will work)
Explain what is meant by the term, “format check”
Checking the user input is of the correct format e.g. a date may be required to be in ‘dd/mm/yyyy’ format.
What is a division by zero error?
If a computer attempts to process any value divided by zero it will crash (the answer is infinity which cannot be represented in binary)
What is reCaptcha and where is it used?
reCaptcha is a method of user authentication where a website tries to ensure the user is human and not a ‘bot. Initially reCaptcha methods used blurred images of text for the user to decipher but as ‘bots have become more sophisticated they have moved onto clicking parts of an image with particular visual clues.
What is terminal testing?
Testing when an entire program is complete to check it functions according to the specification given and meets all success criteria
In the context of test data what do each of the following terms mean: valid invalid valid extreme / valid edge invalid extreme / invalid edge
- valid data is within the acceptable values
- invalid data is outside the acceptable values
- valid extreme / valid edge is only just acceptable
- invalid extreme / invalid edge is only just unacceptable
For example if we need a value of age to be between 8 and 80 we might use: -8 invalid 7 invalid extreme / invalid edge 8 valid extreme 40 valid 80 valid extreme 81 invalid extreme 350