Producing robust programs

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/42

flashcard set

Earn XP

Description and Tags

defensive design, maintainability, testing, syntax and logic errors and refining

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

43 Terms

1
New cards

input validation (defensive design)

checking data input by user meets criteria before processing

2
New cards

type check

if input is correct data type

3
New cards

range check

if input is in correct range

4
New cards

presence check

data has been entered

5
New cards

format check

if input is in correct format

6
New cards

length check

if input has correct number of characters

7
New cards

look-up table

checks data against table of acceptable values

8
New cards

verification

data entered twice

9
New cards

anticipating misuse:

division by 0

ALU cannot compute this

10
New cards

division by 0 correct code

if num !=0:
average=total/num
else:
print("No score enterred")
11
New cards

communication error

when connection to host server is dropped, unable to be established or server is overloaded

12
New cards

what can happen to program in communication error

program could crash or hang

13
New cards

what programmer should do in communication error

allow user to cancel requests or report connection error

program may be able to resume when connection available again

14
New cards

printer and other peripheral errors

if program outputs hardcopy and printer runs out of paper/ink or jams

15
New cards

what programmer should do in printer error

programmer should have option to reprint

16
New cards

disk errors:

programs that read and write files have to deal with

  • file/folder not being found

  • disk being out of space

  • data in file being corrupt

  • end of file being reached

17
New cards

disk errors:

how programs deal with this

checking file and data before further processing

18
New cards

authentication

data must be secured

19
New cards

methods of authentication

  • username and password to access systems

  • recovering password by clicking link withing email that is sent to registered address

  • encrypting data files

20
New cards

reCAPTCHA

protects against online bots automatically submitting data to online forms

verifies if user is human

21
New cards

what programmer should be aware of in authentication errors

SQL injection hacks

22
New cards

maintainability

maintaining code to be clear for group work or editing said code in future

23
New cards

using comments for maintainability

  • explain purpose of program

  • explain sections of code

  • explain unusual approaches that were necessary

  • visually divide sections of program

24
New cards

using white space for maintainability

make sections of programs easier to see

25
New cards

using indentation for maintainability

use it for every selection and iteration branch

26
New cards

using procedures/functions for maintainability

  • structure code

  • eliminate duplicating code

27
New cards

using descriptive variable names and constants for maintainability

28
New cards

reasons for testing

  • ensure there are no errors

  • check program has acceptable performance and usability

  • ensure unauthorised access if prevented

  • check program meets requirements

29
New cards

iterative testing

  • each module tested as it is written

  • branches checked for functionality

  • checks new modules dont introduce new errors

  • tests to ensure program handles erroneous data and exceptional situations

30
New cards

when iterative testing performed

whilst software is being developed

31
New cards

final/terminal testing

  • tests all modules work together

  • tests program produces required results with normal, boundary, invalid and erroneous data

  • checks program meets requirements with real data

  • beta test may find more errors

32
New cards

when final/terminal testing performed

when program finished

33
New cards

syntax error

rules of language have been broken and program cannot run

34
New cards

why syntax errors happen

  • variables not declared before use

  • incompatibility of variable types

  • using assignments incorrectly

  • spelling mistakes

35
New cards

logic error

program runs but does not give expected output

36
New cards

why logic errors happen

  • conditions and arithmetic operations are wrong

  • sequence of commands is wrong

  • division by zero

  • exceptions

37
New cards

suitable test data

  • normal

  • boundary

  • invalid

  • erroneous

38
New cards

normal input

accepted data

39
New cards

boundary input

data on edge of accepted value range

40
New cards

invalid input

data outside of range

41
New cards

erroneous input

incorrect data type

no input

42
New cards

ways of refining code

  • writing code anticipating range of inputs

  • making sure bad data doesnt crash program

  • making sure prompts to user are descriptive

  • making sure only correct data type entered

  • checking and handling missing data

43
New cards

example of refining code

simple exception handling commands