Software Design & Development: Unit 1 - Programming Paradigms Flashcards

1
Q

What is a programming paradigm?

A

It is a specific style of programming (i.e. Imperative, Concurrent and Object Oriented)

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

What is Imperative Programming?

A

A type of language used to create programs consisting of a set of commands

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

What are the 3 basic control structures of Imperative Programming?

A
  • Sequence
  • Selection
  • Iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the ‘sequence’ control structure in Imperative Programming?

A

When one command is executed followed by another in Imperative Programming

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

What is the ‘selection’ control structure in Imperative Programming?

A

If a condition is true then one command is executed, else if that condition is false then a different command is executed

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

What is the ‘iteration’ control structure in Imperative Programming?

A

A command is executed a set number of times

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

What are variables in Imperative Programming? (2)

A
  • They are used to store values in a program, which can be changed.
  • They are passed as parameters to procedures and functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is ‘modularity’ in Imperative Programming?

A

When commands are combines into a single block of self-contained code that can be used within a program to change values of parameters passed into them

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

What are the advantages of ‘modularity’ in Imperative Programming? (3)

A
  • Modules can be treated as separate sub-programs which can be tested independently of the main program
  • Large programming projects will benefit from a modular approach because several different people can work on different modules simultaneously
  • Code will be more readable because the main part of a program can be presented as a concise set of commands, that call a procedure or function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Object-Oriented Programming?

A

A style of programming allowing a program to be separated into blocks of related data, and the operations which apply to that data.

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

What is an ‘object’ in OO programming?

A

A block of related data and the operations which apply to that data, where the data can only be accessed directly by its associated operations.

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

What is a ‘class’ in OO programming?

A

A class is a blueprint for an object, and when it is defined any number of objects can be created from that class.

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

What must be included in a ‘class definition’ in OO programming?(2)

A
  • Instance Variables (or properties), which is what data the class needs to use
  • Methods, which is what the class will be able to do with data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a ‘class library’ in OO programming?

A

A set of classes that can be used by developers as common building blocks for complex applications

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

Explain superclasses and subclasses in OO programming

A

The superclass establishes a common interface and foundation, which subclasses can inherit, modify, and append

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

What is ‘inheritance’ in OO programming?

A

This is where a subclass is created which inherits the instance variables and methods of the class above it, but can have additional instance variables and methods of its own

17
Q

What is an advantage of using ‘inheritance’ in OO programming?

A

There is no need to repeat lines of code to define instance variables or methods, as subclasses will simply inherit these from their superclass

18
Q

What is an actual parameter? What is a formal parameter?

A
  • Actual parameters are parameters as they appear in function calls
  • Formal parameters are parameters as they appear in function declarations
19
Q

What is ‘encapsulation’ in OO programming? (2)

A
  • This is where an objects properties would be hidden and inaccessible outside the a class or subclass.
  • Code within the methods of the class can manipulate the properties of that class
20
Q

What is Concurrent Programming?

A

A style of programming where several streams of operations may execute simultaneously, and can also communicate and interfere with one another

21
Q

What are 3 potential problems that can occur in Concurrent Programming?

A
  • Deadlock
  • Race Condition
  • Resource Starvation
22
Q

What is ‘Deadlock’ in Concurrent Programming?

A

This is when two threads are waiting for the other to finish and as a result neither does.

23
Q

What is ‘Race Condition’ in Concurrent Programming?

A

This is when two threads are potentially racing against each other to update or access a variable

24
Q

What is ‘Resource Starvation’ in Concurrent Programming?

A

This is where the priority given to one or more threads means that they continuously access resources which are needed for another thread.

25
Q

What are the advantages of Concurrent programming? (2)

A
  • Complex programs can make better use of multiple resources in new multi-core processor architectures
  • A user can interact with applications while tasks are running (i.e. stop downloading in web browser)