SSD - 1. Programming Paradigms Flashcards
What is a class?
A class is a blueprint that sets out what data the object can use (its instance variables) and what it can do (its methods)
What are instance variables?
These are the variables that the object can use once created
What are methods?
Methods are the instructions that tell the object what it can do and how it can change the data in instance variables. Methods are defined in the class that was used to create the object. Methods can be function methods (always return one value) or procedure methods (may or may not return a value).
What is an object?
An object is an instance of a class and it inherits the methods and instance variables of that class
What is instantiation?
Instantiation is the process of creating an object from a class
What is inheritance?
This is when a new object receives the instance variables and methods that were defined in the class
What is encapsulation?
Encapsulation is the idea that objects are closed systems and their instance variables and methods cannot be modified from the outside
What are messages?
Messages are how objects tell other objects to perform a task such as run. They are also used to pass data between objects
What is concurrent programming?
Concurrent programming is allowing various processes to share access to the processors at the same time
What is a thread?
A thread is a task or a process that needs access to resources (a sequence of instructions)
What can streams sometimes do (negative)?
Streams can sometimes communicate and interfere with each other
What can streams do?
Streams of threads can run concurrently, maximising the use of processors. A stream is a set of threads that need to run at the same time.
What are the advantages of threads?
- Tasks can run while users are interacting with applications
- Tasks that take a long time to run will not delay tasks that only need a short time to run
- complex programs can make better use of multiple resources in new multi-core processor architectures
What problems are there with multi-threaded programs?
- Deadlock - Two threads competing for processor time, each waiting for the other to finish. Both in a waiting state.
- Race condition - Two threads may need access or alter the same variable. A system needs to lock threads from accessing the same variable
- Resource starvation - A thread accesses resources, locking out lower priority threads. Lower priority threads do not get access. Thread scheduling needs to ensure that all threads get access to necessary resources
What is concurrency control?
Concurrency control is a system that coordinates the interactions between threads so that they are all correctly scheduled and resources are shared among operations based on the priority assigned to a thread