Section 12 - Object-Orientated Programming - USE NOTES Flashcards
(42 cards)
What is a procedural language?
A program consisting of:
- Step-by-step instructions
- Function and procedure calls
- Local and global variables
How does procedural programming work?
Code is broken down into a number of smaller modules, with the program consisting of a series of calls to procedures and functions, each of which may in turn call other procedures or functions
How does object orientated programming work?
The world is viewed as a system of objects, each of which is responsible for its own data and the operations on that data. All processing carried out is done by the objects
What are attributes?
Data that is associated with the class
What features do objects have?
- Attributes
- State
- Behaviours
What are states?
The value of an objects instance variables
What are behaviours?
Actions that can be performed by an object
What is a class?
A blueprint or template for an object that defines the attributes and behaviours of those objects
What is a method?
Attributes and behaviours of an object, they are the functionality of a class
What is a constructor?
Something used to create objects in a class
What are setter methods?
Procedures
What are getter methods?
Functions
What is instantiation?
Where a new object (an instance of a class) is created
Can multiple instances of the same class be created?
Yes, they will share identical methods and attributes, however the value of their attributes will be unique to each instance
What is a reference type variable?
Variables that hold a pointer or reference to where the object itself is stored
What is a variable reference diagram?
A graphical form showing how objects are referenced by reference variables
What is an instance of a class?
Objects created from that class
What is encapusaltion?
All the data and methods of an object are combined into a single entity so that the attributes or behaviours of one object cannot affect the way in which another object functions
What is a subclass?
A “child” class in object-orientated programming
Why do programmers use encapsulation?
- Different programmers can work on different classes and not have to worry about how other parts of the system may affect any code they write
- They can use methods from other classes without having to know how they work
How can you determine whether to use inheritance?
Use the “is a” rule. Ask “is object A an object B?”, and if it is then object A should inherit the data and behaviours from object B
What is a superclass?
A “parent” class in object-orientated programming
What is an inheritance diagram?
A diagram showing the inheritance relationship between different classes
What is inheritance?
Child classes inherit data and behaviours from their parent class