3 - Logic and Languages Flashcards
(37 cards)
What are the Binary situations?
0 - False
1 - True
What are Truthtables?
Shows output from all possible combinations of inputs from a boolean expression.
AND - both 11
OR - either 01 or 10
NOT - 0=1 1=0
What are data validation routines?
Ensure data entered is the right type. Ensure data is reasonable and conforms to set rules
What are the 5 types of Validation check and explain each one
Range - within a sensible/allowed range
Type - right type
Length - not too long or short
Presence - data has been entered
Format - checks for correct format e.g. email/password
What is verification?
Double checks data has been type in correctly
What is Defensive design?
Considerations when designing a program to be secure and robust.
Anticipating misuse
Input Sanitisation
Validation
Verification
Authentication
Maintanable code
What are Authentication routines?
Make sure person is who they say they are
What are password routines?
Commonly ask for usernames and password. if user ID not found, error message displayed.
User given few attempts to correctly enter password. Anticipating misuse - hackers may try dozens of likely passwords.
What are maintainable programs?
Maintained to improve code, fix bugs, or add new features to the program. Can be carried out by multiple programmers.
How should programs be written to be more maintanable?
Subprograms (Functions and Procedures)
Appropriate naming conventions
Indentation
Commenting
Why should subprograms be used?
Well written ones take inputs through parameters and return a value if necessary.
Written so they can be reused multiple times in a program.
Why is indentation used?
Easily see which lines are part of different structures
Why is commenting used?
Helps you understand code when you return to it and helps other programmers understand your code.
What are the two types of errors?
Syntaxc errors - Code written does not conform to rules of the language. ( Compiler does not know how to translate the program into machine code and therefore syntax error)
Logic error - Program will run but not as intended
What do we test for when testing for logic errors?
Normal data
Boundary data
Invalid data
Erroneous data
How can we find logic errors
Using tracetables
What are tracetables?
Useful for determining algorithm’s purpose, finding ouput and finding errors.
What are the two types of testing and explain them?
Iterative testing - tests modulus and parts of program as it is developed. Programme rtest code with knowledge of how it works.
Final (terminal) testing - tests whole program et end of production. As the whole program is being tested, they won’t necessarily know how it works.
What is Machine code?
Binary
Each instruction does one very small task
Writing programs is difficult and time consuming.
What is Assembly language and give examples?
Allows programmer to create programs more easily than writing machine code. Processor specific and has to be translate to machine code before execution. Low level language.
e.g.
LDA - load
ADD - add
STO - store
What are low level languages and what are their advantages?
Corresponds directly to machine code instruction.
Run quickly
Use less RAM
Statements can be used to control and manipulate specific hardware components.
What are high level languages and how do they work?
Look like english and are easier to learn and understand. Have data structures + live arrays and records.
Translation is done by a compiler or interpreter.
E.g.
Python can be run on different types of processors. Different compilers or interpreters used for each type of processer to translate source code (programmer) into machine code for that processor
What are the advantages of High level languages?
Easier to learn
Faster writing of programs
Easier to understand and debug
What are translators and what do they do?
Convert high level language into machine code
Compilers
Interpreters