2.3 Producing Robust Programs Flashcards

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

What does input validation do?

A

Input Validation is checking data input by the user meets specific criteria / rules before processing.

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

Why do we use Input validation?

A

By using Input validation the program is more:

  • Robust
  • User Friendly
  • Prevent Errors occurring later in the algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the types of checks

A

Troubled
Lemons
Race
Funny
Pumpkins

  • Type Check
  • *Check whether data is the right type**
  • Range Check
  • *In data in the correct range. E.g. 1- 10**
  • Presence Check
  • *Is the data actually there. It rejects blank inputes**
  • Format Check
  • *Is the data in the right format. E.g. dd/mm/yy**
  • Length Check
  • *Is it the right length. E.g. Password is too short or too long**
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some of the issues you have to anticipate?

A
  • Dividing by Zero.
  • Communication Error
  • Printer or Peripheral Error
  • Disk Error

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
5
Q

How is Dividing by 0 a problem?

A

In mathematics, there is no number which when multiplied by zero returns a non-zero number. Therefore the ALU cannot compute a division by zero.

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

How is Communication error a problem?

A

Online systems require connections to host servers.

If this connection is dropped, unable to be established or the server is overloaded,

it could potentially cause a program to crash or hang when loading/saving data.

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

How is Peripheral error a problem?

A

Any peripheral may be in an error mode (e.g. paper jam)

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

How is Disk error a problem?

A

Programs that read and write to files must handle exceptions, including:

  • The file/folder not being found.
  • The disk being out of space.
  • The data in the file being corrupt.
  • The end of the file being reached
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Authentication?

What are the ways it can be achieved?

A
  • Authentication is the process of a user confirming that they are who they say they are on a computer system.

This can be achieved with:

  • Username and password to access systems
  • Recovering a password requiring clicking on a link within the email that is sent to the registered address
  • Encryption of data files
  • Check for human and not bot attempting access (e.g. reCAPTCHA)

The factors of authentication can be broken down into three main groups:

something you are - username, bank account number, or anything that identifies the user uniquely
something you know - password, pin, secret answer to a question
something you have - swipe card, biometrics

  • Programmers should also be aware of the potential for SQL injection hacks and other used by hackers.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you increase Maintainability of a program? wcidpc

A

Comments, white space, indentation, variable names, procedures and constants

  • Use Comments to Explain the purpose of program & sections of code. Typically selections, iterations and procedures. They can also explain unusual approaches.
  • Use white space to make sections of a program easier to read as it stands out more
  • Use Indentation for selection and iteration allows the programmer to easily see which code falls within the selection or iteration, and where it ends.
  • Use descriptive variable names and explain their purpose with a comment when declared.
  • User procedures and/or function to Structure the code & Eliminate duplicating portions
  • Use constants declared at the top of the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why do we test our program?

A
  • To ensure there are no errors(bugs) in the code.
  • To check that the program has an acceptable performance and usability
  • To ensure that the unauthorised access is prevented
  • To check the program meets the requirements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is iterative testing?

A

Performed whilst the software is being developed

  • Each new module is tested as it is written.
  • Program branches are checked for functionality.
  • Checking new modules do not introduce new errors I not 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
13
Q

What is terminal testing?

A

Performed when the program is finished

  • 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 meetings the requirements with real data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are Syntax errors

A
  • The rules of the language have been broken
  • The program will not run (Compiled languages)

Syntax errors happen because:

  • Variables are not declared or initialised before use
  • Incompatibility of variables types e.g. total = “A”
  • Using assignments incorrectly
  • Keywords misspelt
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are logic errors and why do logic errors happen

A

The programs run 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are normal inputs?

A

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

17
Q

What are boundary/extreme inputs?

A

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

18
Q

What are invalid inputs?

A

invalid is Data of the correct type but outside accepted validation checks.

19
Q

What are erroneous inputs?

A

Erroneus Data of the incorrect type which should be rejected by a computer system.

This include no input being give when one is expected.

20
Q

How do you refine algorithms to make them robust?

A
  • Code should anticipate all inputs and it should deal with ‘bad’ data, or missing data, and not crash.
  • It should ensure prompts to the user are helpful and that the input can only be of the correct type
21
Q

What are structure diagrams and their benifits?

A
22
Q

What is defensive design?

A

Defensive design considerations

Defensive design is contingency planning using validation, sanitisation, authentication, maintenance and testing.

The purpose of defensive design is to ensure that a program runs correctly and continues to run no matter what actions a user takes. This is done through planning for all possibilities (contingencies) and thinking about what a user may do that the program does not expect.

Defensive design encompasses three areas:

  • protection against unexpected user inputs or actions, such as a user entering a letter where a number was expected
  • maintainability - ensuring code is readable and understandable
  • minimising/removing bug
23
Q

Why do we Test?

A

• To ensure there are no errors (bugs) 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