2.3 Producing robust programs Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Methods of anticipating misuse

A

-input validation
-division by 0
-communication error
-printer and other peripheral errors
-disk errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Anticipating misuse - input validation

A

-checking data input by the user meets specific criteria/ rules before processing
-makes the program more robust, user friendly, prevents further errors occurring later in the algorithm
-does checks:
type - correct data (integer, real, string)
range - correct range (1-2)
presence - data has been entered
format - correct format (dd.mm.yyyy)
length - correct number of characters (pw)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Anticipating misuse - division by 0

A

-ALU cannot compute a division by 0 - could crash a program
-a programmer should always check that a variable is not zero before attempting a division by it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Anticipating misuse - communication error

A

-if connection is dropped, potentially causes a program to crash when loading/ saving data
-programmer should enable ways for the user to cancel requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Anticipating misuse - printer & other peripheral errors

A

-if a program outputs a hardcopy, the printer may run out of paper, ink, have a jam
-programmer should not assume that the output to a printer was successful and always have options to reprint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Anticipating misuse - disk errors

A

-Programs that read and write files need to handle many exceptions
-file/ folder not found
-disk out of space
-data in the file is corrupt
-the end of the file being reached
-robust programs will handle all these situations by checking files and data before attempting to use them for further processing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Anticipating misuse - authentication

A

-Usernames passwords to access systems
-recovering a password requires clicking on a link within the email that is sent to the registered address
-encryption
-reCAPTCHA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Anticipating misuse - maintainability

A

-use comments - explains purpose of the program, unusual approaches that were necessary, visually divide sections of a program
-indentation
-follow naming conventions -descriptive variable names
-use of subprograms -structure the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Purpose of testing

A

-to ensure there are no errors in the code
-To check that the program has an acceptable performance and usability.
-To ensure that unauthorised access is prevented.
-To check the program meets the requirements.
-Iterative testing, final/ terminal testing, syntax error, logic error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Testing - iterative testing

A

-Each new module is tested as it is written.
-Program branches are checked for functionality.
-Checking new modules so new errors are not introduced to existing code.
-Tests to ensure the program handles erroneous data and exceptional situations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Testing - final/ terminal testing

A

-Testing that all modules work together (integration testing)
-Testing the program produces the require results with normal, boundary, invalid and erroneous data.
-Checking the program meet the requirements with real data.
-A beta test may find more errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Testing - syntax error

A

-The rules of the language have been broken.
-The program will not run (compiled languages).
-Syntax errors can happen because:
-Variables are not declared or initialised before use.
-Incompatibility of variables types e.g. total = “A” (total declared as an integer)
-Using assignments incorrectly e.g. 2+2 = x
-Keywords misspelt e.g. prnt(“Enter choice: ”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Testing - logic error

A

-The program runs but does not give expected output.
-Logic errors can happen because:
-Conditions and arithmetic operations are wrong.
-Sequence of commands is wrong.
-Division by zero.
-Exceptions e.g. file not found.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Types of suitable test data inputs

A

-normal inputs
-boundary inputs
-invalid inputs
-erroneous inputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Suitable test data - normal inputs

A

Data which should be accepted by a program without causing errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Suitable test data - boundary inputs

A

Data of the correct type which is on the edge of accepted validation boundaries.

17
Q

Suitable test data - invalid inputs

A

Data of the correct type but outside accepted validation checks.

18
Q

Suitable test data - Erroneous inputs

A

Data of the incorrect type which should be rejected by a computer system.
-This includes no input being given when one is expected.