Section 11 Programming Techniques Flashcards

1
Q

Programming Constructs

A

● Sequence
○ Code is executed line-by-line, from top to bottom
● Branching
○ Particular block of code is run if a specific condition is met
○ Uses IF and ELSE statements
● Iteration
○ Can be either:
■ Count-controlled
● Block of code executed a certain number of times
■ Condition-controlled
Block of code is executed while a condition is met
○ Uses FOR, WHILE or REPEAT UNTIL loops

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

Global and Local Variables

A

Local Variables
● Can only be accessed within the subroutine in which they were defined
● Multiple local variables with the same name can exist in different subroutines
● Are deleted once subroutine ends
● Using local variables ensures subroutines are self-contained
Global Variables
● Can be accessed across the whole program
● Useful for values that need to be used by multiple parts of the program
● Danger of being unintentionally edited
● Not deleted until program terminates, so require more memory

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

Scope

A

the section of code in which the variable can be accessed

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

A local variable within a subroutine

A

takes precedence over a global variable
with the same name

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

Modular programming

A

● Modular programming is a technique used to split large, complex programs
into smaller, self-contained modules
● Easier to divide tasks between a team and manage projects
● Simplifies the process of testing and maintenance, as each component can be
dealt with individually
● Improves reusability of components

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

Top-down Design/ Stepwise Refinement

A

Technique used to modularise programs
● Problem is broken down into sub-problems, until each is represented as an
individual, self-contained module which performs a certain task
● Modules form blocks of code called subroutines

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

Functions and Procedures

A

● Both named blocks of code that perform a specific task
● Procedures do not have to return a value
● Functions must always return a single value
● Parameters can be passed into a subroutine either by value or by reference

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

Passing by Value

A

● A copy of the value is passed to the subroutine and discarded at the end
● Its value outside of the subroutine remains unaffected

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

Passing by Reference

A

● Address of parameter is given to the subroutine
● Value of the parameter will be updated at the given address

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

In exam questions, you should assume parameters are passed

A

by value unless you
are told otherwise. The following format will be used:

function multiply(x:byVal, y:byRef)

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

Use of an IDE (Integrated Development Environment)

A

Program which provides a set of tools to make it easier for programmers to
write, develop and debug code
● Features of IDEs include:
○ Stepping
○ Variable watch
○ Breakpoint
○ Source code editor
○ Debugging tools

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