2.3.1 - Defensive Design Flashcards
1
Q
What is anticipating misuse
A
- Ensuring a program caters for all possible inputs no matter how far fetched they are
- This is done by sending messages to correct user inputs
2
Q
What is authentication and how is it proved
A
- A process used to verify the identity of the user so only the correct user can access data
- It can be proved by a PIN, username and password, biometrics or personal information e.g. mothers maiden name
3
Q
What is verification
A
Asking a user to input some information such as a password twice to ensure it is them
This is a part of authentication
4
Q
What is input validation and why is it needed
A
- Ensures data entered is reasonable and sensible and in the right format
- Reduces the risk of incorrect data crashing a program
5
Q
Types of validation checks
A
- Presence check
- Data type check
- Format check
- Length check
- Range check
6
Q
What is a presence check
A
- Makes sure a value is inputted and the user doesn’t accidentally leave something blank
- Example code: if answer != “ “ then
7
Q
What is a data type check
A
- Makes sure the data entered is of the correct type e.g, only integers are entered as an input
8
Q
What is a range check
A
- Checks the upper and lower boundaries to make sure the users input is inbetween sensible values e.g. age for a game is inbetween 7-99
9
Q
What is a length check
A
- Limits the data entered to make sure it is not too short or too long
10
Q
What is maintainability and methods of doing it
A
- Making sure a program is easy to undersand or to modify
- Indentation
- NAming conventions
- Using subprograms
- Commenting
11
Q
What is indentation
A
- Where some lines of code are forward a few spaces
- This is used in selections and iterations
- They make it easier for the programmer to see where these loops are
Python auto indents but some other programming languages don’t
12
Q
What are naming conventions
A
- Giving variables sensible names that reflects the purpose of the variable and the data it stores
- This allows other programmers to understand what the variables are used for
13
Q
What is commenting
A
- # or //
- Allows for English communication of what certain parts of the code does
- Documents the creator and who edits as well
- this allows it to be maintained long after it was created
14
Q
What are subprograms and the different types of subprograms
A
- Breaking the code into smaller parts with each subprogram having a set role to produce structure code
- Functions - used to read data, manipulate it and send it back to the main program (return)
- Procedures - performs a task but doesn’t return a value
15
Q
Advantages of subprograms
A
- Saves time - can be saved as separate modules and used in other programs
- Small so easy to write, test and debug
- Shorter programs - can be called multiple times and only has to be written once