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