2.2.1 Programming techniques Flashcards

(19 cards)

1
Q

What is sequencing?

A
  • Code is executed line-by-line top to bottom
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is branching?

A
  • Section of code is only run if specifc condition met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is iteration?

A
  • Block of code executed more than once
  • Count-controlled: certain number of times
  • Condition-controlled: while condition is met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is recursion?

A
  • Programming construct where sub-routine calls itself
  • Continues until base case is met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Advantages of recursion?

A
  • Code can be represented in fewer lines
  • 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

Variable facts

A
  • Defined with either global or local scope
  • Scope is section of code which variable can be accessed
  • Local variable with same name is subroutine overwrite global variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a local variable?

A
  • Defined within subroutine
  • Can only be accessed within subroutine
  • Are deleted when subroutine ends
  • Ensures subroutines are self contained
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a global variable?

A
  • Can be accessed across entire program
  • Useful for values which are accessed often
  • Risk being unintentionally edited
  • Not deleted therefore more memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is modularity?

A
  • Splitting large programs into smalled self-contained modules
  • Easier to divide tasks between team
  • Each component can be tested individually
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are functions and procedures?

A
  • Sections of code that perform specific task
  • Procedures dont return value
  • Functions return single value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is passing by value?

A
  • Copy of value is passed to subroutine
  • Creates local copy
  • Value outside subroutine is unaffected
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is passing by reference?

A
  • Address of parameter passed into subroutine
  • Value of parameter updated at given address
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are IDEs?

A
  • Program that provides set of tools to help programmers develop and debug code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Features of IDEs?

A
  • TREE: translators, run time env, error diagnostics, editing
  • CASA: Colour coding, automatic indentation, stepping, autocomplete
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a class?

A
  • Template used to create objects
  • Contains attributes defining object state
  • Contains methods defining object behaviour
17
Q

What is encapsulation?

A
  • Attributes cannot be directly edited or accessed
18
Q

What is inheritence?

A
  • Child class inherits methods and attributes of parent class
19
Q

What is polymorphism?

A
  • Inherited methods produce different outputs to that of parent class