Computer Science - 2B Programming Techniques

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards

Subroutine

giving an identifier to a block of code. Allows us to reuse that code throughout the program

2
New cards

Procedure

just executes code without returning a value

3
New cards

Function

executes code and returns a value

4
New cards

Parameters

data fed into a subroutine to be used within its code. Defined in the brackets after the subroutine's identifier

5
New cards

Return

returns a value from a subroutine

6
New cards

Why use subroutines? [5]

- modularised approach breaks down programs into manageable chunks of code
- helps to decompose larger problems
- programmers only need to use the interfaces of subroutines, i.e. parameters and return values
- don't need to worry about internal workings
- programs will have fewer bugs as we use structured programming techniques

7
New cards

Local variable

only exist inside the structure they are defined in (I.e. subroutine, while loop, if statement etc.)

8
New cards

Global variable

exist everywhere in the code. Must be defined outside of any structures (I.e. not indented)

9
New cards

Scope

the part of a program where a variable is visible and can be used by the code.

10
New cards

Advantage of using local variables:

keep a subroutine self-contained for use in any program, so variable names will not conflict

11
New cards

Structured programming techniques

techniques consisting of top-down program design, pseudocode, flowcharts, and logic structures

12
New cards

Data validation

ensuring that users enter the correct data type

13
New cards

Different validation routines [5]:

- range check
- type check
- length check
- presence check
- format check

14
New cards

range check

ensures a field is between a certain range of values.

15
New cards

type check

data is of the right type, such as integer, letter or text

16
New cards

length check

checks data is correct length

17
New cards

presence check

requires a field to be completed.

18
New cards

format check

checks the data is in the right format

19
New cards

Data verification

double-check that data has been typed in correctly

20
New cards

Authentication routines

used to make sure a person is who they claim to be

21
New cards

Examples of authentication routines [3]:

- ask for user ID and password
- biometrics
- reCAPTCHA

22
New cards

Maintainable code [5]:

- comments at the top for who wrote the program and when
- comments to explain complex code
- subroutines have comments to explain their use
- meaningful variable names
- modular structure

23
New cards

Trace table

a table that follows the values of variables to check for accuracy/function of program

<p>a table that follows the values of variables to check for accuracy/function of program</p>
24
New cards

What is a trace table useful for? [3]

- determining the purpose of an algorithm
- finding the output of an algorithm
- finding errors in an algorithm

25
New cards

Logic error

a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly

26
New cards

Syntax error

an error in a program that makes it impossible to parse — and therefore impossible to interpret

27
New cards

What types of test data are there? [3]

- normal data
- boundary data
- erroneous data

28
New cards

Normal data

entering data that should be acceptable to the solution

29
New cards

Boundary data

data either side of the range extremes

30
New cards

Erroneous data

test data that a program isn't designed to accept