Topic 8 - Producing robust programs Flashcards
Structure diagrams
- they decompose the program into smaller, more manageable modules – that eventually perform individual tasks
advantages of using structure
( E, LofP, R )
- coding is easier as you are only coding very simple tasks
- lots of programmers can work together as each module can be written independently
- can reuse sub programs in future programs
defensive design
Defensive design ensures that programs function properly and never produce errors
how do programmers try to protect their programs through defensive design?
- anticipate how users might misuse their program then prevent it
- ensure the code is well maintained
- reduce number of errors in code through testing
Why is it important that code is well-maintained?
so it is easy for other programmers to understand what the code does, so they can use the code
how can you make code more maintainable?
- Indentation
- Meaningful variable names
- Subroutines
- Comments
Indentation
- groups together functions
- ## makes longer programs much easier to read and follow
comments
- explains the code and its function in more detail
- using psuedocode that all programmers will understand
- can also inform other programmers of a bug or issues
meaningful variable names
- variables should be named to refer to what they actually are
- they should also be easy to read and use capital letters and underscores to make it easier to read
subroutines
they give a program structure
- easier to see how different parts of a program come together
Input validation
checking if data meets certain criteria before passing it into the program
types of input validation
- format check
- data type check
- length check
verification
checks if the input has been entered correctly ( not double entry or no entry )
authentication
method of confirming the identity of the user before allowing them access to the program
how do programmers use authentication
- passwords associated with usernames
- biometrics
- limit the number of failed authentication attempts before access to an account is lost
- strong passwords
Iterative testing
-program is tested as it is developed, line by line
- used to fix small errors which prevent larger errors later on
final testing
-program is tested at the end of the development process
- modules may work perfectly on their own but errors may occur when the modules interact with each other
what are errors?
mistakes in the program code that causes the program to run incorrectly
logic errors
when the compiler/interpreter is able to run the program but produces an unexpected result
syntax error
when the compiler/interpreter can’t understand a part of the program because it doesn’t follow the grammar/rules of the language
how are logic errors diagnosed
they are harder to find as compilers/interpreters can’t pick them up.
- test plans & general use of program
how are syntax errors diagnosed
by compilers/interpreters as they won’t be able to run the program and return a syntax error ( with location)
test plan
anticipates all the potential issues with program and selects appropriate test data ( normal, boundary, erroneous, invalid )
invalid data
values higher or lower than the expected range
erroneous data
incorrect data types that the program shouldn’t accept