Intro to CS: Lecture 17 - Python Classes
Topics: Object Oriented Programming: data abstraction, class def, class instances, methods
More review for me. I don’t mind reviewing though. We start by defining an object, along with examples.
Advantages of OOP
- Bundle data into packages together with procedures that work on them through well-defined interfaces
- Divide and conquer development
- Implement and test behavior of each class separately
- Increased modularity reduces complexity
- Classes make it easy to reuse code
- Many python modules define new classes
- Each class has a separate environment (no collision on function names)
- Inheritance allows subclasses to redefine or extend a selected subset of a superclass’ behavior
The Power of OOP
- Bundle together objects that share
- Common attributes and
- Procedures that operate on those attributes
- Use abstraction to make a distinction between how to implement an object vs. how to use an object
- Build layers of object abstractions that inherit behaviors from other classes of objects
- Create our own classes of objects on top of python’s basic classes