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