2.3 Programming Robust Programs Flashcards
Define defensive design
Defensive design helps to ensure programs function properly. This means that programs should never break or produce errors.
Define anticipating misuse
Anticipating misuse involves thinking ahead about how users might misuse the program. They will then design the program to prevent this happening. Preventing too many entries of a
password to make it harder for hackers to guess
Define authentication
Authentication can confirm the identity of a user before they’re allowed to access particular data or programs.
Define input validation
Input validation is checking that the data meet certain criteria before passing it into the program e.g. checking that an email address contains an @ symbol.
Define maintainability
Well maintained programs make it easy for other programmers to understand your code. This can include using sub programs, comments, indent, clear naming.
Define syntax error
When the compiler or interpreter does not understand something you have typed, because it does not follow the rules or grammar of the programming language.
Define logic error
When the compiler or interpreter is able to run the program, but the program does something unexpected.
Define iterative testing
The program is tested while it is being developed. Often a programmer will test a module, fix any errors and then test it again.
Define final testing
Final testing – the program is tested at the end of the development process. The whole program is tested at the same time to check it is all working.
Define test plan
The test plan will outline exactly what you are going to test and how you are going to test it. Good test plan will anticipate all potential issues with the program
Define normal data
Data that the user is likely to input into the program.
Define boundary data
Values at the limit of what the program should be able to handle.
Define invalid data
Inputs with the correct data type that should be rejected by the program.
Define erroneous data
Inputs with an incorrect data type that should be rejected by the program.
Range check
A number or date is within a sensible or allowed range
Type check
Data is of the right type e.g integer
Length check
Text entered is not too long or too short
Presence check
Checks that data has been entered
Format check
Checks that the format is correct e.g email address or postcode
What is validation?
Ensures data entered is sensible, reasonable and allowed
What is verification?
Double checks that the data has been entered correctly
Password routines
Once an ID and password has been entered it is looked up in a database. If the ID cannot be found, an error message is displayed.
Why are programs maintained?
Improve code, add new features, fix bugs
What makes a program maintainable?
Sub programs
Appropriate naming conventions
Indentation
Commenting
Why are sub programs used?
Take inputs and return a necessary value, allowing them to be reused multiple times within the main program. They include functions and procedures.
Why are appropriate naming conventions important?
Makes the code easier to read and understand, includes appropriately named functions, procedures, variables and constants.
Why is indentation important?
Helps to see which lines of code are part of which structure
Why are comments important?
Helps other programmers to easily understand what is going on in the code
What are comments usually written for?
Parts of a program or algorithm that are difficult to understand, at the start of a function or procedure,
What are comments not usually written for?
Every line, to explain obvious parts of code, to explain syntax
Verification
Checking whether data has been entered correctly e.g double entry
Input sanitisation
Cleaning up data that has been input
Validation
Checking whether input data follows criteria
Maintainable code
Allowing other programmers to understand the code
Lookup table
A table of acceptable entries