2.2.6. Programming Techniques Flashcards

1
Q

Sequence

A

the code is executed line by line, from top to bottom (sequentially)

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

Branching/ selection

A

BRA - always branch
BRP - branch if the value is positive (or zero)
BRZ - branch if the value is zero
A certain block of code is run if a specific condition is met, using IF statements

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

Iteration

A

A block of code is executed a certain number of times (FOR loop) or until a condition is met (WHILE loop)

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

What is Recursion

A
  • Where a subroutine calls itself within its own subroutine until a (stopping) condition is met.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Advantage of Recursion

A

The code is represented in fewer lines of code

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

Disadvantages of Recursion

A
  • inefficient use of memory. If the subroutine calls itself too many times, there is a risk of stack overflow which will cause the program to crash
  • errors within recursion are difficult to trace
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Global Variables

A

Can be accessed across the whole program

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

Global variable disadvantages

A
  • can be unintentionally overwritten

- requires more memory as they aren’t deleted once the subroutine is completed.

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

Local variables

A

local variables have a limited scope which means that they can only be accessed within the subroutine in which they were defined in

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

Local variable advantages

A
  • ensures subroutines are self-contained (good practice in coding)
  • multiple local variables with the same name can exist in different subroutines (won’t overwrite each other)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Modularity (top-down programming)

A

Splitting large, complex problems into smaller self-contained modules
- makes it easier to divide tasks between a team as each component is self contained

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

Procedure and function similarity

A

Procedures and functions are both named blocks of code that perform a specific task

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

Procedure vs function

A

Procedures don’t have to return a value whereas a function must always return a value

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

IDEs

A
  • A program which provides a set of tools to make it easier to write, develop and debug code
  • Debugging tools have run-time detection of errors to show where they may have occurred
  • Stepping which allows you to monitor the effect of each individual line of code by executing line by line
  • Source code editor which provides features such as autocompletion of words, indentation, syntax highlighting and automatic brack completion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Class

A
A class is a template for an object and defines the state and behaviour of an object
It is not an object itself. It is a template used to set or define what attributes and methods an object has.
Once you have defined a class, you can easily reuse that class and create many objects of that class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Inheritance

A

subclasses inherit methods and attributes from the superclass. Using inheritance, you can reuse the code from a class and extend its attributes and methods.

17
Q

Encapsulation

A

When attributes are made private.
Public methods are needed to read/ amend the attribute’s value
- used to hide values or the internal state of an object preventing direct access by unauthorised third parties
- reduces human error

18
Q

Object Orientated Techniques

A

Attempts to capture or group info and data and related functionality (code) into structured items known as objects.