Producing Robust Programs Flashcards

1
Q

What is Defensive Design?

A

Defensive Design helps to ensure programs function/run properly and continue to run no matter what actions a user takes. This means that programs should never break or produce errors.

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

What is Anticipating Misuse?

A

Anticipating Misuse is thinking ahead about how users might misuse the program. They will then design the program to prevent this happening.

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

What is Authentication?

A

Authentication can confirm the identity of a user before they are allowed to access particular data or programs.

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

What is Input Validation?

A

Input Validation is checking that the data meets certain criteria before passing it into the program.

e.g. Checking that an email address contains an @ symbol.

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

What are the various types of validation?

A

Range Check
Length Check
Presence Check
Format Check
Type Check

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

What is a Range Check?

A

The input must fall within a specified range. This is usually applied to numbers and dates, but can apply to characters.

For example, the number entered must be between 1 and 100.

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

What is a Length Check?

A

The input must not be too long or too short.

For example, a username will require at least one letter, but can’t have more than 20.

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

What is a Presence Check?

A

A data value must be entered.

For example, entering a quantity when placing an order.

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

What is a Format Check?

A

The data must be in the correct format.

For example, entering a date in the format DD/MM/YYYY.

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

What is a Type Check?

A

The data must be of a specified data type.

For example, an integer must be entered when specifying a quantity.

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

What is a disadvantage of Validation Checks?

A

Validation does not ensure that the data entered is correct, just that it is possible and sensible. A user may accidentally enter a date of birth that is possible and sensible, but incorrect. The program has no way of knowing that the date has been entered incorrectly.
To get around this, many programs include verification checks - they repeat the entered data to the user and ask them to confirm if this data is correct. If the user confirms the data, the program then assumes it to be correct. This is an example of how planning the design of a program can help reduce errors.

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

What is Maintainability?

A

A well-maintained program makes it easy for other programmers to understand your code. This can include using sub programs, comments, indents, clear naming

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

What things are included in making Maintainability?

A

Naming conventions
Indentation
Commenting
Use of sub-programs

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

What is Naming Conventions?

A

Choosing a variable name that reflects the purpose of the variable and the
data it is intended to hold, instead of variables like x,y,z.
(makes the program more understandable)

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

What is Indentation?

A

Code within selections or iterations should be indented. This allows the programmer to easily see which code falls within the selection or iteration, and where it ends.
(makes the program more understandable)

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

What is Commenting?

A

Comments are lines in programs that provide information about what the different parts of the program do. They serve no other purpose, and are not executed when the program is run - the program simply ignores them and moves on to the next line of code.
(makes the program more understandable)

17
Q

What are Sub-programs?

A

Subprograms are small programs that are written within a larger, main program. The purpose of a subprogram is to perform a specific task. This task may need to be done more than once at various points in the main program.

18
Q

What are the two types of Sub-programs?

A

Procedures
Functions

19
Q

What is a Procedure?

A

Procedures carry out a set of instructions and do not return a value.

20
Q

What is a Function?

A

A function is a similar to a procedure but it will return a value.

21
Q

What is a Parameter?

A

Procedures or functions may be given variables to use.
These are called parameters.
Parameters are passed to a sub program.

22
Q

What are benefits of using Sub-programs?
How do Sub-programs improve Maintainability?

A

The main benefit that is fact sub programs give a program structure.
This makes it easier to follow and understand.

A subprogram may be used repeatedly at various points in the main program. However, the code only has to be written once, resulting in shorter programs.

Subprograms are usually small in size, meaning they are much easier to write, test and
debug.

23
Q

What are the two types of error that often occur when developing a program?

A

Syntax error
Logic error

24
Q

What is a Syntax Error?

A

Error in a program resulting from code that has been entered not following syntax rules or grammar rules governing how to write statements in a programming language.

  • misspelling a statement, eg writing pint instead of print
  • using a variable before it has been declared
  • missing brackets, eg opening a bracket but not closing it
25
What is a Logic Error?
Error in a program which does not cause a program to crash but causes unexpected results. - incorrectly using logical operators - incorrectly using Boolean operators - incorrectly using brackets in calculations - incorrectly using brackets in calculations
26
What is the difference of the effect on a program between a syntax error and a logic error?
A program will not run if it has syntax errors. Any such errors must be fixed first. Unlike a syntax error, a logic error will not usually stop a program from running. Instead the program will run but not function as expected.
27
What is the purpose of Testing?
The purpose of testing is to help the programmer remove bugs and to ensure that the program functions as intended.
28
What are the two types of Testing?
Iterative Testing Final (terminal) Testing
29
What is Iterative Testing?
The program is tested while it is being developed. Often a programmer will write a section of code and will then test a module, fix any errors and then test it again. The process repeats (iterates) until the module works as intended.
30
What is Final Testing?
Final (terminal) testing is carried out when all modules are complete and the program is tested as a whole to ensure that it functions as it should.
31
What is a Test Plan?
The Test Plan will outline exactly what you are going to test and how you are going to test it. A good test plan will anticipate all potential issues with the program. It indicates: - the test number - the data entered - the type of test data - the expected outcome - the result of the test - action required as a result of the test.
32
What is Test Data?
Test data is data that is used to test whether or not a program is functioning correctly.
33
What are the three types of Test Data?
Normal Boundary (Extreme) Invalid (Erroneous)
34
What is Normal data?
Sensible, possible data that the program should accept, be able to process and data that the user is likely to input into the program. (accepted by program)
35
What is Boundary/Extreme data?
Data that falls at the boundary/limit of any possible ranges that the program should be able to handle. (accepted by program)
36
What is Invalid/Erroneous data?
Overall definition - data that the program cannot process and should not accept/should reject. Invalid data - Inputs with the correct data type that should be rejected by the program. Erroneous data - Inputs with an incorrect data type that should be rejected by the program.