(GCSE ARCHIVE) Algorithms, Design, and Testing Flashcards
What is structured programming?
Structured programming involves decomposing a program into smaller manageable modules. Each of these modules is then decomposed even further repeatedly until eventually reaching modules that perform specific tasks.
What are the advantages of structured programming?
- Coding is easier because you’re only writing subroutines that carry out very simple tasks
- Lots of programmers can work on one program as each module can be written independently.
- It’s easier to test structured programs as each module can be tested individually.
- You will be able to reuse the subroutines and modules in programs you write in the future.
- Individual subroutines and modules can be fixed and updated without affecting the rest of the program.
What is authentication?
The process of verifying the identity of a user before they’re allowed to access anything, such as through passwords.
Ways of increasing the security of a password-based authentication system
- Limit the number of failed authentication attempts a user can have before locking their account for safety.
- Force users to use strong passwords that cannot be easily guessed.
- Force users to regularly change their passwords.
What is input validation?
Checking if data meets certain criteria before passing it into the program. An example would be checked that a phone number only has numbers in it.
What are the 5 types of common input validation checks?
- Range checks
- Presence checks
- Format checks
- Length checks
- Look-up table
Range check
Checks the data is within a specific range of values.
Presence check
Checks that data has actually been entered.
Format check
Checks the data has the correct format (e.g. a date).
Look-up check
Checks data against a table of acceptable values.
Length check
Checks the data is the correct length (e.g. a password must be between 8-20 characters).
Ways to improve the maintainability of code
- Only use global variables when necessary, as they could affect the rest of your code (e.g. somebody else uses the same variable name as you).
- Use local variables in subroutines instead, as they don’t affect anything outside of the subroutines they’re in.
- Variables, subroutines, and parameters should be named appropriately, and refer clearly to what they are. This avoids confusion later on and makes it easier to keep track of what each variable does.
- Comments (written after # or //) are useful for explaining the key feature of a program. Clear and well written comments are important to help other programmers understand your program.
What are the 2 types of errors in programming?
- Syntax Error: When the compiler/interpreter doesn’t understand something you’ve typed, because it doesn’t follow the rules or grammar of the programming language.
- Logic errors: When the compiler/interpreter is able to run the program, but the program does something unexpected.
Why is it harder to find the source of a logic error?
- Syntax errors can be diagnosed by a computer, and they often return the line of code in which a syntax error is found.
- Logic errors aren’t picked up by compilers/interpreters, as the code still follows the syntax. Logic errors are found through systematically testing a program using a test plan.
What are the three types of test data?
- Normal data: Typical, sensible data that the program should accept.
- Boundary (extreme) data: Valid or invalid data that is on either side of the boundary of what the program should accept as normal. data.
- Erroneous data: Invalid data that the program should not accept.