3 Programming constructs
Sequence, Selection, Iteration
Difference between Sequence construct and Algorithmic thinking
Algorithmic thinking is used to create a set of step by step logical instructions but sequence executes this instructions in a specific order
AND, OR, NOT gates
AND A ^ B
OR A v B
NOT ¬ A
Defensive design 1 - Input validation
Tyra Ran Proudly Leaping Foxes
Type
Range
Presence (Has data been entered)
Length (No. of characters)
Format (dd/mm/yy)
Defensive design 2 - Anticipating misuse
‘Fail gracefully’
Division by 0
Communication error (option to restart connection)
Hard disk error (checks data in case corrupt or insufficient storage capacity)
Peripheral error (option for reprint in case no ink)
Defensive design 3 - Authentication
Username and password
Can limit number of login attempts to prevent brute force attacks
Defensive design 4 - Input sanitisation
Keeps data safe by removing harmful, unexpected data which can be used for SQL injections
Defensive design 5 - Maintainability
Comments
Relevant variable names
Indentation
Sub programs
4 IDE tools
Editor
Error diagnostics (break point)
Run time environment (allows program to run on computers and checks for run time errors
Interpreters/Compilers
Translation
Source code (high level language) converted to machine code (binary) using compiler or interpreter. Compilers require recompilation after editing and can’t pinpoint errors but they optimise code and allow it to run faster
SQL
SELECT (* or field)
FROM (table)
WHERE (condition)
2D arrays
2D=[[1,2,3],[3,2,1]]
File editing
File= open(“file.txt”,”w”)
File.write(“123”)
File.close()
“a” appends
“r” reads
“w” writes new file or overwrites existing one