2.3 - Programming Robust Programs Flashcards
Name some defensive design considerations
- Anticipating misuse
- Input sanitisation
- Validation
- Verification
- Authentication
- Maintainable code
How can anticipating misuse help in defensive design considerations?
Planning ahead to take steps against potential misuse
How can inputting sanitisation help in defensive design considerations?
Cleaning up data that has been input
What is Validation?
A process to check that data is reasonable or sensible before it is accepted
What is Verification?
Checking whether data has been entered correctly
What is maintainable code?
Allowing other programmers to understand the code
Give some examples on maintainable code
- Comments
- Indentation
- Meaningful variable names
How can authentication help in defensive design considerations?
Ensuring only authorised users can gain access to a system
What are the types of input validation?
- Range
- Type
- Format
- Presence
- Lookup Table
- Length
What is a Range check?
Checks data is within a certain range
What is a Type check?
Checks data is a certain data type
What is a Format check?
Checks data is entered in a certain way
What is a Presence check?
Checks that data has actually been entered and not left blank
What is a Lookup Table?
A table of acceptable entries
What is a Lookup table also known as?
A List
What is a Length check?
Checks the length of the input is within a certain amount
How does using constants help to improve maintainability?
Keeps the program code consistent
—> Makes it easier to read and debug a program
What is modularisation?
Using subprograms to reuse code and make them easier to test
How does using appropriate variable names help to improve maintainability?
Ensures the purpose of a variable is immediately understood
What is the main purpose of testing?
To ensure a program works correctly no matter what input has been entered by the user
Give some other reasons on why programs should be tested
- User requirements have been met
- Errors have been removed
- Program doesn’t crash while running
What are the types of testing?
- Iterative testing
- Final testing
When does iterative testing take place?
During program development
Describe how iterative testing works
Programmer develops a module, tests it and repeats this process until the module works as expected
When does final testing take place?
After development & before the program is released to the end user
What is final testing also known as?
Terminal testing
What are the types of programming errors?
- Syntax
- Logical
What is a syntax error?
A mistake in the grammar or spelling of the program
—> Prevents program from being compiled
What is the difference between a logical error and a syntax error?
Logical
Still works but displays wrong output
Syntax
Program won’t be compiled and won’t work at all
What is a logical error?
A mistake made by the programmer
(still works but displays the wrong output)
What is the purpose of test data?
Used to test whether a program is functioning correctly
What should test data cover?
Range of possible & incorrect inputs
What are the types of test data?
- Normal data
- Boundary data
- Invalid data
What is invalid data also known as?
Erroneous data
What is normal data?
Sensible data that the program should accept & be able to process
What is boundary data?
Data at the extreme boundary of any data changes
What is invalid data?
Data that the program cannot process & should not accept