Programming Paradigms COPY Flashcards
What are the three basic control structures?
Sequence
Selection
Iteration
Describe the features of Imperative Programming
Set of commands which can be called by name
Pass parameters between blocks of code
Modularity
Give two advantages of modular coding
- Can be tested independently of the main program
- Can be re-used within the program
- Split up large programming problems
- Makes code more readable
List the main features of Object Orientated Programming
Classes Objects Methods Encapsulation Instance Variables Inheritance
What can be used to describe a class?
Class Diagram
What is Instantiation?
Creating an object from a class(blueprint) that is already defined
Give a benefit of inheritance
Once a class has been defined and tested, sub-classes can then be created which share the main characteristics of parent class -Saves testing and development time
What is the ability to redefine methods in object orientated programming?
Polymorphism
Describe what happens in Concurrent Programming
Several streams of operations may execute simultaneously
Describe a ‘race condition’
When two threads both try to change the value of a variable simultaneously resulting in unpredictable results
What is it called when two threads are competing for the same resource resulting in neither of them completing their operations?
Deadlock
What is done to prevent race conditions occurring?
Placing a lock on shared data so only one thread can access it at a time
What is resource starvation?
Priority is constantly given to one thread, preventing other lower priority threads accessing the data needed for completion
What is resource starvation caused by?
Poor scheduling
Prioritizing
What is concurrency control?
Ensuring operating happens in the correct order and access to resources is co-ordinated so they are shared among threads according to their priority
State some advantages of concurrent programming
A user can interact with applications while other tasks are running
Long running tasks need not delay short running ones
Complex programs can make better use of multiple resources in multi core processors