Software Design & Development: Unit 1 - Programming Paradigms Flashcards
What is a programming paradigm?
It is a specific style of programming (i.e. Imperative, Concurrent and Object Oriented)
What is Imperative Programming?
A type of language used to create programs consisting of a set of commands
What are the 3 basic control structures of Imperative Programming?
- Sequence
- Selection
- Iteration
What is the ‘sequence’ control structure in Imperative Programming?
When one command is executed followed by another in Imperative Programming
What is the ‘selection’ control structure in Imperative Programming?
If a condition is true then one command is executed, else if that condition is false then a different command is executed
What is the ‘iteration’ control structure in Imperative Programming?
A command is executed a set number of times
What are variables in Imperative Programming? (2)
- They are used to store values in a program, which can be changed.
- They are passed as parameters to procedures and functions
What is ‘modularity’ in Imperative Programming?
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
What are the advantages of ‘modularity’ in Imperative Programming? (3)
- 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
What is Object-Oriented Programming?
A style of programming allowing a program to be separated into blocks of related data, and the operations which apply to that data.
What is an ‘object’ in OO programming?
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.
What is a ‘class’ in OO programming?
A class is a blueprint for an object, and when it is defined any number of objects can be created from that class.
What must be included in a ‘class definition’ in OO programming?(2)
- 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
What is a ‘class library’ in OO programming?
A set of classes that can be used by developers as common building blocks for complex applications
Explain superclasses and subclasses in OO programming
The superclass establishes a common interface and foundation, which subclasses can inherit, modify, and append
What is ‘inheritance’ in OO programming?
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
What is an advantage of using ‘inheritance’ in OO programming?
There is no need to repeat lines of code to define instance variables or methods, as subclasses will simply inherit these from their superclass
What is an actual parameter? What is a formal parameter?
- Actual parameters are parameters as they appear in function calls
- Formal parameters are parameters as they appear in function declarations
What is ‘encapsulation’ in OO programming? (2)
- 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
What is Concurrent Programming?
A style of programming where several streams of operations may execute simultaneously, and can also communicate and interfere with one another
What are 3 potential problems that can occur in Concurrent Programming?
- Deadlock
- Race Condition
- Resource Starvation
What is ‘Deadlock’ in Concurrent Programming?
This is when two threads are waiting for the other to finish and as a result neither does.
What is ‘Race Condition’ in Concurrent Programming?
This is when two threads are potentially racing against each other to update or access a variable
What is ‘Resource Starvation’ in Concurrent Programming?
This is where the priority given to one or more threads means that they continuously access resources which are needed for another thread.
What are the advantages of Concurrent programming? (2)
- 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)