U2b - Programming techniques Flashcards

1
Q

Examples of subroutines

A

Functions, procedures

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

What’s the difference between a function and a procedure?

A

Procedures execute code in a subroutine but they don’t return anything. Functions will return a value after processing has taken place e.g. input returns what the user typed in, random returns a number

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

Define parameters

A

Values that you can pass through a subroutine

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

Advantages of subroutines (4)

A
  • Each subroutine can be tested separately to make sure it works correctly
  • Many programmers can work on a large program at the same time which cuts down development time
  • Subroutines can be re-used in other programs
  • Program maintenance is easier - if you make a mistake, then you only have to modify the subroutines affected
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Difference between global and local variables

A

Global variables are outside of the subroutine, whereas local variables can only be seen and used inside the subroutine

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

What are global variables?

A

Variables that are accessible anywhere in the program. They’re written in pseudocode using the global keyword

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

What are local variables?

A

Variables that only exist while the subroutine is executing. They are only accessible within the subroutine.

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

Advantage of using local variables

A

They keep a subroutine self-contained, so they can be used in any program without variable names conflicting with those used in the calling program

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

Advantages of using structured programming techniques (2)

A
  • The modularised approach of using subroutines breaks down programs into manageable chunks of code, and this helps to decompose larger problems
  • By using structured programming techniques, programs will have fewer bugs and be easier to maintain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define scope

A

The area of a program where an item is recognised

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

Define subroutine

A

A selection of code that can be grouped together under a name, and then called later in the program

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

Define data validation

A

Routines that ensure that data entered is of the right type

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

Define range check

A

Ensures that a number or date is within a sensible/allowed range

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

Define type check

A

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

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

Define length check

A

Ensures that text entered is not too long or too short e.g. a password between 8 and 15 characters

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

Define presence check

A

Ensures that data has been entered i.e. the field has not been left blank

17
Q

Define format check

A

Ensures that the format of something is correct e.g. DD/MM/YY and not MM/DD/YYYY

18
Q

What’s the difference between validation and verification

A

Validation can only check that the data entered is reasonable, but verification checks that the data entered is correct

19
Q

Give an example of double-entry verification

A

A user setting a new password being asked to type it in twice. If the two passwords don’t match, they will be asked to enter the password again

20
Q

Define authentication

A

A routine used to make sure a person is who they claim to be e.g. username and password

21
Q

Ways to make code easier to understand and maintain (5)

A
  • Write comments at the top to show who wrote the program and when they wrote it
  • Comments to explain what harder parts of the code do
  • Each subroutine should have comments to explain their functionality
  • Using meaningful identifiers
  • Using a modular structure
22
Q

Why is a trace table useful (3)

A
  • For determining the purpose of an algorithm
  • For finding the output of an algorithm
  • For finding errors in an algorithm
23
Q

Define syntax error

A

An error where the code written doesn’t conform to the rules of the language. The program cannot be run until all syntax errors are fixed

24
Q

Define logical error

A

An error where the program will run, but it won’t work as the programmer intended

25
Q

Examples of test data

A

Normal, boundary and erroneous