Computational Thinking (III) - Design, Testing and IDEs Flashcards
For a computer language to be processed what must happen?
It needs to be translated into machine code
What are the advantages of high level programming languages?
They are close to the spoken and written language of the programmer making it much easier to work with
Name some high level languages
Python
Java
C++
C#
Visual Basic
JavaScript
Programs written in high level language are known as what?
Source code
What are low level languages?
They sit close to the computer’s instruction set
What are the two types of low level language?
Machine Code
Assembly Language
What is machine code?
Instructions that a process understands and can act upon
What are the advantages of writing in machine code?
More flexibility
What are the disadvantages of writing in machine code?
Very difficult to write in, understand and debug (consisting of binary and hexadecimal)
When programmers need direct control of machine code, what is used?
Another low level language – assembly language
What does assembly language use?
Mnemonics, for example:
LDA – load a value from a memory address
STA – store a value in a memory address
ADD – adds the value held in a memory address to the value held in the accumulator
SUB – subtracts from the accumulators the value held in a memory address
MOV – moves the contents of one memory address to another
What is Opcode and Operand?
Opcode – actual instructions
Operand – this is a value that the instruction uses or manipulates
What are translators?
A program that converts source code (high level language written program) into object code (a form the computer understand)
What are the three types of translator?
Compilers
Interpreters
Assemblers
What is a compiler?
A compiler takes the source code as a whole and translates it into object code, in one go
What is an interpreter?
An interpreter translates source code into object code one instruction at a time
What is an assembler?
An assembler translates assembly language into object code
What is an IDE?
Tools which are gathered together to help write programs
What is the Python IDE?
IDLE
What are editors?
Editors are software which allow programmers to write and edit code. Editors are often fairly simple, but usually offer facilities such as:
Automatic line numbering Colour coding Auto-correct Auto-suggest Auto-indent
What do editors help with (and are unable to help with)?
Editors help the readability of code
They are unable to help identify errors
What is a runtime environment?
A runtime environment (RTE) is special software that allows a program to run on a computer, even if it is not designed to run on it
What debugging tools exist to locate and fix errors?
Breakpoints (pause / stop code to check)
Variable tracing (identify changing variable values)
Syntax error pinpoint (error trapping)
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
List some defensive design considerations
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
What is validation?
Give some examples
Validation applies rules to inputted data, rejecting it if it doesn’t follow the rules
E.g. range check, length check, presence check, format check, type check etc…
What is data sanitisation?
Hide / protect data so it cannot be seen or disclosed
E.g. masking hides visible data (password entry becomes *****)
What is authentication?
Authentication is the process of a user confirming that they are who they say they are on a computer system
What are the three authentication groups?
Something you are - username, bank account number, or anything that identifies the user uniquely
Something you know - password, pin, secret answer to a question
Something you have - swipe card, biometrics, any other physical identifying device
What is the purpose of maintainability?
To ensure that, over time, a program can be maintained
List how a program can be written in a maintainable style
Comments
Sensible variable names
Indentation
What are the two types of programming error?
Syntax error
Logic error
What is a syntax error?
Give some examples
A syntax error occurs when code written does not follow the rules of the programming language.
Misspelling a statement, e.g. writing pint instead of print
Using a variable before it has been declared
Missing brackets, e.g. opening a bracket but not closing it
What is a logic error?
A logic error is an error in the way a program works. The program simply does not do what it is expected to do (usually the program continues to run).
Give some examples of a logic error
Incorrectly using logical operators, e.g. expecting a program to stop when the value of a variable reaches 5, but using <5 instead of <=5
Incorrectly using Boolean operators
Unintentionally creating a situation where an infinite loop may occur
Incorrectly using brackets in calculations
Unintentionally using the same variable name at different points in the program for different purposes
Referring to an element in an array that falls outside of the scope of the array
What is the difference between iterative testing and final (terminal) testing?
Iterative testing – carried out why a program is being being developed
Final (terminal) testing – carried out when all modules are complete and the program is tested as a whole
What should test data include?
Valid data - sensible, possible data that the program should accept and be able to process
Extreme data - valid data that falls at the boundary of any possible ranges
Invalid (erroneous) data - data that the program cannot process and should not accept
What should a good testing plan include?
The test number
A description of what the test intends to check
The test data being used
The type of test (valid, extreme or invalid)
Expected outcome
Actual outcome
What is a trace table? Complete one for the following code (adding the integers 5, 7 and 9 to make 21)
Trace tables contain all the variable a program contains (and when their value changes, the table indicates this)
What can potentially happen if programs aren’t tested fully?
Bugs