2.2.1 - Programming Techniques Flashcards

Component 2

1
Q

What is a variable?

A

Identifier/name of a memory location used to store data

Used to store a value which can change during execution

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

What are the global variables?

A

The variable can be accessed throughout the scope of the program (visible throughout a program)

Using passing by reference is an equivalent of a global variable.

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

What are the negatives of global variables?

A

Global variables mean that memory space is kept throughout the running of the program, not just the sub-program (which uses more space than local)

Make it difficult to track changes as it can be changed from any other part of the code.

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

What is a local variable?

A

Can only be accessed within the scope of the sub-program where it is created

A parameter that is passed into a subroutine becomes a local variable in the subroutine e.g. LoadLevel(Difficulty)

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

What is an IDE?

A

Integrated Development Environment (IDE) - A program used for developing programs, made from several components.

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

What tools are provided by an IDE to develop software?

A
  • Auto-complete – Will predict variable and built-in functions and finish off the word. Can avoid spelling mistakes and speed up development
  • Syntax highlighting (colour coding text) - Can distinguish between different features quickly to check code is correct
  • Auto Indent – Indents code automatically within structures to avoid errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What tools are provided by an IDE to debug software?

A
  • Error highlighting - Syntax errors highlight dynamically so they can be corrected before running the program (saving time)
  • Variable Watch window – Display the values of the variables during running of the program
  • Break points- Stop the program at set points to check the values of variables. Developer can add multiple breakpoints.
  • Error message list- Tells you where errors are and suggests corrections
  • Stepping - Executes program one line at a time to watch variable values and program pathways
  • Traces - Printouts of variable values for each statement execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the three programming constructs?

A

Sequence

Selection / Branching

Iteration

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

What is an example of a count controlled loop?

A

FOR Loop - Will run for a set number of predetermined times.

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

What is an example of a condition controlled loop?

A

WHILE / DO WHILE - Will run whilst a condition is true or false

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

What are parameters?

A

Parameters are the variables listed between the brackets, after the procedure/function name e.g.

They become local variables in the routines that they are passed to.

characterMovement(inputKey, characterx, charactery)

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

What does passing by value mean?

A

By Value (ByVal)
* Does not override the original data
* A local copy of the data is used
* Data is discarded when the subprogram exits

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

What does passing by reference mean?

A

By Reference (ByRef)
* Changes are made to the original data
* Memory location of data is sent
* Changes remain after the subprogram exits
* Uses less memory

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

What is a function?

A
  • A named block of code which always returns a value
  • Uses the keyword return
  • Assigns the returned value to a variable (e.g. y)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a procedure?

A
  • A named block of code which does not return a value
  • Does not use the keyword return
  • Is called by writing its name but not assigning the result to a variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly