Week 2: Object Oriented Programming
Outcomes
You should be able to:- Write or identify a definition for
- Functions
- Methods
- Class
- Object
- Encapsulation
- Abstraction
- Inheritance
- Polymorphism
- Constructor
- __init__
- Override(s)
- Magic Methods
- Subclass
- Superclass
- Read class-based pseudocode and explain/identify the goal of the code [Continued from last week]
- Read existing Python code and connect it to corresponding pseudocode [Continued from last week]
Activities
- Schafer's Videos - Getting Started with Object Oriented Programming
- If you care, here are the PowerPoint Slides from the videos
- Motivating Object Oriented Programming [Video, 6 minutes]
- The Concepts and Vocabulary of Objects [Video, 20 minutes]
- There is a lot of detail in here.
- Focus on the big picture and the general meaning behind the four pillars.
- Come to an understanding on the vocabulary of the four pillars.
- But don't worry about being a detailed expert.
- There is a lot of detail in here.
- Looking at code for the a Python class, version 1
- Walkthrough video [Video, 26 minutes]
- CreditCard.py [Code, a typical Python class]
- WalletRunner.py [Code, a simple program that uses several instances of the Credit Card class.
- Modifying the CreditCard to explain the idea behind magic methods
- Walkthrough video [Video, 12 minutes]
- MagicCreditCard.py [Code]
- List of Magic Methods
- The Fraction Class (different code from what will be in your textbook. Same basic idea)
- Walkthrough video [Video, 14 minutes]
- Schafer's version of Fraction.py [Code]
- Slightly ImprovedFraction.py [Code]
- Textbook Reading
- Section 1.13.1
- This is long and detailed
- But it covers most everything you need to know about objects
- Section 1.13.2
- This starts to get a bit more confusing.
- The semi-important aspect of this is the concept of inheritance and not the actual implementation of the inheritance in the Logic Gates example.
- Pay attention to the discussions about inheritance more than any code itself.
- Cross reference this with the discussion about inheritance from my videos above.
- Section 1.13.1
- Checking your understanding of OOP vocabulary
- Consider a couple of non-programming scenarios that model OOP pillars.
- My answer key.
- You Do It (YDI) Activity #2
- Activity Part 1 (for all) - Consider what a Python Class for a Scratch Sprite would do/look like
- Activity Part 2 (optional) - Create/write the Python Class code for the design created in part 1
- I will repeat, I do NOT expect you to be able to write a Python class as an outcome of this course.
- But some of you might be interested in trying. This is your opportunity to TRY.
- My solution is below.
- Activity Part 3 (for all) - Examine my solution code and consider how this code provides what we built in Part 1
Additional Resources
- If you think you are starting to get it but you want to hear it ONE MORE TIME from a different source, consider the following resources I really like:
- How to Explain OOP to a 6 year old.
- A good article to revisit the 4 pillars of Object Oriented Programming
- Object Oriented Programming in 7 minutes video
- You may want to turn on the closed captioning
- Grab the book you used in FCCS
- Read pp 350-356
- How to Explain OOP to a 6 year old.
- You may have noticed this on the table of contents page for your textbook. Professor Gerry Jenkins is a retired professor from Long Beach City College who made a bunch of videos to correspond with the readings in your textbook. I have NOT viewed all of them. But, I know how helpful it can be to have a wide variety of study resources.
- Videos 15 - 20 on this playlist correspond to material we covered this week. (To be more accurate, 15-17 align with our course. Videos 18-20 go into deeper detail on things mostly beyond the scope of this course.
- If you find this information about programming languages interesting you might grab your book from FCCS and read pp 306-316 to read about the evolution and different types of of computer programming languages
- For this course we are most interested in the material on OOP on pp 315-316
- Having said that, the material on 306-314 is stuff that you might read in the big picture of things.