Defensive design Flashcards
What is the purpose of defensive design?
to ensure that a program runs correctly and continues to run no matter what actions a user takes. This is done through planning for all possibilities (contingencies) and thinking about what a user may do that the program does not expect
What 3 areas does defensive design encompass?
- protection against unexpected user inputs or actions, such as a user entering a letter where a number was expected
- maintainability - ensuring code is readable and understandable
- minimising/removing bugs
How is the anticipation and protection of a program carried out?
through.... validation sanitisation authentication maintenance testing
What does validation do?
checks data and inputs to ensure that it is sensible or reasonable.
What types of validation can be built into a program?
- Range check
- Length check
- Presence check
- Format check
- Type check
What does a range check do?
checks that the input must fall within a specified range
What does a range check apply to?
numbers and dates, but can apply to characters.
What does a length check do?
that the input isn’t too long or too short
What does a presence check do?
checks that data has been entered
What does a format check do?
check that the data is in the correct format, such as entering a date in the format DD/MM/YYYY.
What does a type check do?
checks that the data is of a specified data type, such as an integer
Does validation ensure that data entered is correct?
No, only that data is sensible
What is a verification test ?
inputting data twice so that if the 2 entries match, the entry can be accepted as valid
What is data sanitisation?
to hide or protect data so it can’t be seen or disclosed.
What are the examples of data sanitisation?
masking and input sanitisation
What does masking do?
Masking hides visible data by replacing it with something else. A good example of this is when a person enters a password.
.
.
What is an example of input sanitisation?
A good example of this is on a website form. A hacker might try to gain access to a website’s data through a SQL injection attack. This would involve the hacker entering an SQL command into a website form to try and take control of the form’s linked database. Input sanitisation could be used here to remove any SQL commands from the inputted data, preventing a hacker from gaining control of the database.
What is authentication?
the process of a user confirming that they are who they say they are on a computer system.
What are the main factors of authentication?
something you are - username, bank account number, or anything that identifies the user uniquely
something you know - password, pin, secret answer to a question
something you have - swipe card, biometrics, any other physical identifying device
What is the purpose of maintainability?
Ensuring that a program is easy to understand, modify and update over time
What are examples of maintainability in use?
comments
sensible variable names
indentation
What are comments?
lines in programs that provide information about what the different parts of the program do
What should variable names do?
reflect the purpose of the variable and the data it is intended to hold
Why is indentation used?
so you can see which code falls within the selection or iteration, and where it ends.
What is the difference between syntax and logic errors?
Syntax errors occur when written code does not match the rules of the programming language. Logic errors occur when the program does not perform as expected.
What is the purpose of testing?
The purpose of testing is to help the programmer remove such bugs and to ensure that the program functions as intended.
What is iterative testing?
Iterative testing is carried out while a program is being developed. The programmer writes a section of code (module) then tests it. The module may work fine, but more likely the programmer will amend or fix the code, and test it again. The process repeats (iterates) until the module works as intended.
What is final testing?
Final (terminal) testing is carried out when all modules are complete and the program is tested as a whole to ensure that it functions as it should.
What is normal data?
sensible, possible data that the program should accept and be able to process
What is boundary data?
valid data that falls at the boundary of any possible ranges
What is invalid data?
Data which is outside the limits of valid data
What is erroneous data?
Data that is unacceptable e.g the wrong data type
What does a trace table do?
a trace table, contains all the variables a program contains. Whenever the value of a variable changes, the change is indicated in the trace table.
What does a trace table help with?
Identifying logic errors