Chapter 58 - Use of object - oriented techniques Flashcards
What is procedural language?
» Uses a series of step-by-step instructions on how to solve the problem
» Breaks down into a number of smaller modules - consists of functions or procedures
Where is the data held in procedural programming?
» Held in seperate primitive variables such as integer or char, or in data structures such as array, list or string
How is everything viewed as in object-oriented programming?
» As a collection of objects
What are the attributes?
» The features of the object
» Variables contained within and associated to an object
What are methods?
» The behaviour of the object
» Actions that can be pefromed by an object
What is the class?
» A blueprint or template for an object/multiple
» Defines the attributes and behaviours of objects in that class
How are attributes declared as?
» Declared as private
How are methods declared as?
» Public
What is the principle of information hiding?
» Where a class cannot directly access the attributes of another class, when they are declared private
What is a constructor?
» A special type of method to construct/build objects in a class
What instantiation?
» Process of creating new instances of a class
What are objects and instance?
» Synonymous
What is a reference variable?
» The object, where memory locations stores the data
What is the purpose of a variable reference diagram?
» Shows in graphical form the object referenced by the variables
What is an object?
» An instance of a new class
What are instances?
» Objects that belong to a class
What is the principle of encapsulation?
» When an obejct ecapsulates both its states - the values of its instance variables
» So it doesnt affect any other objects
How can you initialise a class and a constructor?
» class example1:
def__init__(,s,):
self.s = s
How can you use a getter?
» def get_name():
return name
How can you use a set name?
» def set_name(self):
self.name = name
What does init stand for?
» Initalise
What are getters?
» To make use of information - we need methods that give us access to data
What does a get method do?
» Allows the attribute to be accessed/returned
What does a set method allow?
» The attribute to be changed with parameters
What is inheritance?
» Where a class, inherits the attributes and moethods of a ‘parent’ class, as well as having their own
What happens when you create a subclass?
» You inherit all the attribute and methods of the superclass
What are the 3 benefits of using inheritance in your program?
» Avoid repeating code
» Organise classes and objects into a hierarchy
» Share methods and attributes between difference classes
What is the parent class?
» Also known as the Super class
» Is the class being inherited form, also called base class
What is the child class?
» Is the class that inherits from another class, also called derived class