2.3.1 - Defensive Design
No description yet. This curated deck is ready for daily study.
Card preview (15)
What is anticipating misuse
• 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
What is authentication and how is it proved
• 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
What is verification
Asking a user to input some information such as a password twice to ensure it is them This is a part of authentication
What is input validation and why is it needed
• Ensures data entered is reasonable and sensible and in the right format • Reduces the risk of incorrect data crashing a program
Types of validation checks
• Presence check • Data type check • Format check • Length check • Range check
What is a presence check
• Makes sure a value is inputted and the user doesn’t accidentally leave something blank • Example code: if answer != “ “ then
What is a data type check
• Makes sure the data entered is of the correct type e.g, only integers are entered as an input
What is a range check
• 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
What is a length check
• Limits the data entered to make sure it is not too short or too long
What is maintainability and methods of doing it
• Making sure a program is easy to undersand or to modify • Indentation • NAming conventions • Using subprograms • Commenting
What is indentation
• 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
What are naming conventions
• 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
What is commenting
• # 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
What are subprograms and the different types of subprograms
• 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
Advantages of subprograms
• 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