Session Overview
In this lecture, we learn about object-oriented programming (OOP) and how classes are used to implement new types of objects in Python. As part of that discussion we introduce inheritance. Image courtesy of The Ridg on Flickr. |
Session Activities
Lecture Videos
- Lecture 11: OOP and Inheritance (00:49:37)
About this Video
Topics covered: Object-oriented programming (OOP), abstract data types, specifications, subclasses, inheritance.
Resources
Recitation Videos
-
Recitation 5: Quiz 1 Answers and Object-Oriented Programming (00:53:38)
Recitation 5: Quiz 1 Answers and Object-Oriented Programming
> Download from iTunes U (MP4 - 116MB)
> Download from Internet Archive (MP4 - 116MB)
About this Video
Topics covered: Double recursion, big O notation, binary function, run times, object-oriented programming, classes, encapsulation, methods, class hierarchy, subclasses, inheritance, polymorphism, accessor and mutator functions, Person example, underbar methods, self parameter.
Check Yourself
What is an instance?
› View/hide answer
Instances are the actual objects built in accordance with the qualities of the class.
What is an abstract data type?
› View/hide answer
A set of objects and the operations on those objects.
What is encapsulation?
› View/hide answer
Encapsulation means that names (of variables and methods) are stored in locations that then have to be accessed, called namespaces.
What is data hiding?
› View/hide answer
Data hiding makes data invisible to users of the object, requiring it to be accessed only via the object's methods.
What functions can subclasses use?
› View/hide answer
Subclasses can use all the functions of their superclass. They can also use any functions that are defined within the subclass; however, if the subclass uses the same name for a function which has also been used in the superclass, it will only use the subclass definition of that function.