Computer Science - 2B Programming Techniques

studied byStudied by 2 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 29

flashcard set

Earn XP

Description and Tags

30 Terms

1

Subroutine

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

New cards
2

Procedure

just executes code without returning a value

New cards
3

Function

executes code and returns a value

New cards
4

Parameters

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

New cards
5

Return

returns a value from a subroutine

New cards
6

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

New cards
7

Local variable

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

New cards
8

Global variable

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

New cards
9

Scope

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

New cards
10

Advantage of using local variables:

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

New cards
11

Structured programming techniques

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

New cards
12

Data validation

ensuring that users enter the correct data type

New cards
13

Different validation routines [5]:

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

New cards
14

range check

ensures a field is between a certain range of values.

New cards
15

type check

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

New cards
16

length check

checks data is correct length

New cards
17

presence check

requires a field to be completed.

New cards
18

format check

checks the data is in the right format

New cards
19

Data verification

double-check that data has been typed in correctly

New cards
20

Authentication routines

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

New cards
21

Examples of authentication routines [3]:

- ask for user ID and password
- biometrics
- reCAPTCHA

New cards
22

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

New cards
23

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>
New cards
24

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

New cards
25

Logic error

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

New cards
26

Syntax error

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

New cards
27

What types of test data are there? [3]

- normal data
- boundary data
- erroneous data

New cards
28

Normal data

entering data that should be acceptable to the solution

New cards
29

Boundary data

data either side of the range extremes

New cards
30

Erroneous data

test data that a program isn't designed to accept

New cards
robot