Unit 12 - Functional and Object Oriented Programming Flashcards
What are the properties of a first class object?
- It can be assigned to a variable
- It can appear in an expression
- It can be returned in a function call
- It can be assigned as an argument
Define encapsulation
Self containing attributes and methods within a class so they cannot be altered in other parts of the program
Define inheritance
Where a subclass inherits the attributes of a superclass in order to perform different methods
Define composition
A type of aggregation where two classes are reliant on one another, this means they cannot exist independently of one another (if one is deleted the other is deleted as well)
Define aggregation
When one object can own or access another object in a different class
Define polymorphism
Allowing a method in the class hierarchy to behave differently in each class
Define overriding
An attribute or method from a superclass being redefined and extended into a subclass allowing it to behave differently in different classes (an example of polymorphism)
Define overloading
Using the same methods but varying the parameters assigned to them .e.g. using ‘*args’ (an example of polymorphism)
Define method
A function assigned to a class
Define attribute
A piece of data assigned to a class
Define instantiation
Creating an object
Define object
An instance of a class
Define class
A blueprint for an object which defines the attributes for that object and the methods that act on them in order to represent the common characteristics and behaviours of that object
Define constructor
A function used to create objects based on the class
Define default constructor
One that does not accept any additional arguments
Define parameterised constructor
One that accepts arguments in addition to the default
Define interface
A collection of methods with no implementation
Define method signature
The name of the method and the parameters it includes
Define programming paradigm
A style of programming
Define function
A rule that assigns an output from a co-domain to an input from a domain without using all the outputs
Define domain
The set from which a functions inputs are chosen
Define co-domain
The set from which a functions outputs are chosen
Define immutability
A property of a program which means it’s variables cannot change
Define stateless
A program that does not record any data because none of the variables within the program change
Define referential transparency
The idea that functions written in the functional programming paradigm will always return the same result if the same variables are entered because data is immutables
Define function application
When arguments are applied to a function
Define composition of functions
Combining two functions in order to get a new function
Define partial function application
Decomposing larger functions with multiple arguments into smaller functions with fewer arguments
Define high order function
A function that takes a function as an argument or returns a function as an output or does both
Define prepending
Adding an item to the start of a list
Define appending
Adding an item to the end of a list
Define concatentation
Adding two lists together to get a new list
Define Big data
Data that is collected on such a large scale it cannot be stored in one server and it cannot be analysed easily
What are the four main programming paradigms?
Procedural programming, object oriented programming, functional programming and
Why is a default constructor necessary for a class?
A constructor is responsible for assigning values to attributes of a class when an instance of the class is created, this means it creates references to attributes dependent on objects
What is the main difference between OOP and procedural programming?
Procedural programming is heavily reliant on utilising sets of global and local variables to achieve the end result whereas OOP relies on instances of classes being created (objects) which perform functions and can interact with other objects