Object Oriented Languages Flashcards
Class
Template defining the attributes and methods that can be used to create a type of data known as an object.
What does Encapsulation do?
It protects attributes from being directly accessed.
How is encapsulation implemented?
By only allowing class methods to access data in an object’s attributes.
Inheritance
The concept of subclasses inheriting the methods and attributes of its parent class.
Method
A program subroutine that represents an action an object can perform.
Object
An instance of a class, with a set of methods and attributes.
Polymorphism
A property of OOP that means objects can behave differently depending on their class. This can result in the same method producing different outputs depending on the object involved.
What is good about object oriented programming?
- Allows for a high level of reusability. This is good for projects where there are multiple components with similar properties (thanks to inheritance and polymorphism)
- Classes can be used across multiple projects.
- Encapsulation makes code more reliable by protecting attributes from being directly accessed
- Modular structure makes it easy to maintain and update
What is bad about OOP?
- Requires alternative style of thinking as it is a different style of programming.
- Unsuitable for smaller programs
- Where few components are reused, OOP may result in a longer more inefficient program.
Setter
A method that sets the value of a particular attribute.
Getter
A method which retrieves the value of a given attribute.
Why use getters and setters?
To ensure attributes cannot be directly edited and accessed.
How is encapsulation implemented?
By only allowing class methods to access data in an object’s attributes.
Constructor
Creates an instance of a class.
Instantiation
The process of creating an object.