YouTube

Session 9 of Software Lessons, “Object-Oriented Programming (OOP) Part 1: Classes and Inheritance,” runs about 30 minutes.

What this session covers

  • Introduction to object-oriented programming
  • Class syntax
  • Inheritance
  • Types
  • The classic Animal Kingdom example

Key ideas

  • A class is a blueprint that bundles data and the functions that work on that data, and an object is an instance of a class.
  • Inheritance lets a subclass reuse and extend the data and behavior of a parent class.
  • A common teaching example is a general Animal class with more specific subclasses, which shows how shared behavior sits in the parent.
  • Every object has a type, and a subclass instance can be used wherever its parent type is expected.
  • Grouping data with behavior keeps related code together and makes it easier to change one part without breaking others.