2.2.1 Programming Techniques Flashcards

1
Q

Sequence

A

Code is executed line by line from top to bottom

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

Branching

A

Particular block of code is run if a specific condition is met

Uses IF and ELSE statements

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

Iteraction

A

Can either be:
. Count controlled - the code is run a specific number of times
. Condition controlled - the code is run until a specific 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
4
Q

Recursion

A

Programming construct in which a subroutine calls itself in execution
Continues until a stopping condition is met

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

Advantages of Recursion

A

Can be represented in a fewer lines of code
Easier to express some functions recursively

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

Disadvantages of Recursion

A

Risk of stack overflow if memory runs out
Difficult to trace

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

Global and Local variables

A

. Variables can be defined with either global or local scope
. Scope is the section of code in which the variable can be accessed
. A local variable whithin a subroutine takes presedence over a global variable with the same name

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

Local variables

A

. Can only be accessed in the subroutine in which they were defined
. Multiple local variables with the same name can exist in different subroutines
. Are deleted once the subroutine ends
. Using local variables ensures subroutines are self contained

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

Global variables

A

. Can be accessed for 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 requires more memory

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

Modularity, functions and procedures

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
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 task
. Modules from blocks of code called subroutine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
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 by value or reference

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

Passing by value

A

. A copy of the value is passed into 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
14
Q

Passing by reference

A

. Address of the 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
15
Q

IDE (Integrated Development Environment)

A

. A program which requires a set of tools to make it easier for programmers to write, develop and debug code, features 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
16
Q

Use of object oriented languages

A

. Object-oriented languages are bult around the idea of classes

. A class is a template for an object

. Classes define the state and behaviour of an object

. Object state is given by attributes while behaviour is defined by methods

. An object is a particular instance of a class

. Attributes cannot be directly edited in a technique called encapsulation

. Top-down design applies encapsulation to modules, which are also built to be self-contained and reusable

17
Q
A