Unit 8 - Logic and languages Flashcards
What is the purpose of a truth table?
To show all possible inputs and the corresponding outputs
What are the 5 types of defensive design?
- Input sanitation
- Validation
- Verification
- Authentication
- Maintainabe code
What is input sanitation?
Input sanitisation cleaning up input data / removing
unwanted data e.g. removing special characters / preventing SQL injection
What is validation?
Checking whether input data should be allowed / is sensible / follows criteria
What are the 6 types of input validation checks?
- Range
- Type
- Presence
- Length
- Format
- Table
What does a range check do?
checks boundaries
What does a type check do?
making sure the data inputted is of the
correct data type
What does a presence check do?
making sure a value is inputted / not
blank
What does a length check do?
limit number of characters // check
maximum / minimum string length
What does a format check do?
making sure the data inputted follows a
set pattern
What does a table check do?
making sure the data inputted is one from an allowed set of values
What is verification?
checks whether data has been entered correctly
What is authentication?
Authentication ensures only authorised users can gain access e.g using password
How does password routine work?
Commonly, you are asked to enter a User ID
and a password. Once you have entered the User ID, the website looks up your password in a database. If the user ID cannot be found, an error message is displayed
What is program maintainablility?
It is important that programs are written in a way to make them easily maintainable to allow other programmers to understand the code.
What are the 4 ways to maintain a program?
- Comments
- Meaningful variables
- Modularise
- Indentation
How does commenting improve maintainability?
Enables programmers to understand the purpose of each line / section
How does naming variales sensibly improve maintainability?
to enable programmers to understand the purpose of each variable
How does modularisation improve maintainability?
allows reuse / makes easier to test / reduces errors e.g. create as a function
How does indentation improve maintainability?
Indentation makes it possible to easily see which lines of code are part of different structures
What are the 2 types of errors?
- Syntax error
- Logical error
What is a logical error?
- An error that results in incorrect output / unexpected result
- Contains an error but still runs