Skip to content
Computer Science · 9th Grade · Programming with Purpose · Weeks 19-27

Introduction to Object-Oriented Programming (OOP)

Students will be introduced to the basic concepts of OOP, including classes and objects.

Common Core State StandardsCSTA: 3A-AP-20

About This Topic

Object-oriented programming (OOP) is a major shift in how students think about code organization. Instead of writing long sequences of instructions, students learn to model real-world entities as objects, each combining data (attributes) and behavior (methods) into a single unit. The concepts of classes as blueprints and objects as instances of those blueprints are central to nearly every modern programming language and professional codebase.

For 9th graders, the challenge is often conceptual rather than syntactic. Students can memorize OOP vocabulary without understanding what problem it solves. Grounding the introduction in familiar real-world analogies, like a 'Dog' class with breed and name attributes and a bark() method, helps make the abstraction accessible. CSTA 3A-AP-20 specifically calls for students to develop programs that use encapsulation to organize code, making this a skills-based standard with direct implementation expectations.

Active learning is essential here because OOP is inherently collaborative to discuss. When students design classes together and present their attribute choices to peers, they encounter different modeling decisions and learn that class design is a judgment call, not a fixed right answer.

Key Questions

  1. Explain the core principles of Object-Oriented Programming.
  2. Differentiate between a class and an object in programming.
  3. Construct a simple class with attributes and methods.

Learning Objectives

  • Compare and contrast the concepts of classes and objects in programming.
  • Construct a simple class definition in Python, including attributes and methods.
  • Identify the core principles of Object-Oriented Programming: encapsulation, abstraction, inheritance, and polymorphism.
  • Design a basic program that utilizes objects instantiated from a user-defined class.

Before You Start

Introduction to Programming Concepts

Why: Students need a foundational understanding of variables, data types, and basic control flow (loops, conditionals) before learning to organize code using classes and objects.

Functions and Procedures

Why: Understanding how to define and call functions is essential for grasping the concept of methods within a class.

Key Vocabulary

ClassA blueprint or template for creating objects. It defines the properties (attributes) and behaviors (methods) that all objects of that type will have.
ObjectAn instance of a class. It has its own state (values for its attributes) and can perform actions (methods defined by its class).
AttributeA data value or characteristic associated with an object. These represent the state of an object.
MethodA function or procedure associated with an object. These define the behaviors or actions an object can perform.
EncapsulationThe bundling of data (attributes) and methods that operate on the data within a single unit, like a class. It helps control access to data.

Watch Out for These Misconceptions

Common MisconceptionA class and an object are the same thing.

What to Teach Instead

A class is a blueprint; an object is a specific instance created from that blueprint. The 'Car' class defines what all cars have in common, while a specific car like 'my_car = Car("red", "Honda")' is an object. Sorting exercises during class help students consistently apply this distinction.

Common MisconceptionMethods are just functions that happen to be inside a class.

What to Teach Instead

Methods are specifically tied to the state (attributes) of their object. Unlike standalone functions, a method can access and modify the object's data through 'self'. Collaborative class design activities help students see that methods are behaviors particular to that object's data, not generic operations.

Active Learning Ideas

See all activities

Real-World Connections

  • Video game developers use OOP to model characters, items, and game environments. For example, a 'Player' class might have attributes like health and score, and methods like 'move()' and 'attack()'.
  • Software engineers building mobile applications, like ride-sharing apps, utilize OOP to represent entities such as 'Driver', 'Passenger', and 'Trip', each with specific data and actions.

Assessment Ideas

Quick Check

Present students with a simple real-world scenario, such as a library book. Ask them to identify potential attributes (e.g., title, author, ISBN) and methods (e.g., checkOut(), returnBook()) for a 'Book' class. Discuss their choices as a class.

Exit Ticket

Provide students with a pre-written Python class definition. Ask them to write two lines of code: one to create an object from the class and one to call a method on that object. Collect and review their code snippets.

Discussion Prompt

Pose the question: 'Imagine you are designing a system for a pet store. What would be some key classes you would create? What attributes and methods would each class have?' Facilitate a brief class discussion on their proposed designs.

Frequently Asked Questions

What is the difference between a class and an object in Python?
A class is a template that defines the structure and behavior shared by a group of things. An object is a specific instance created from that template. For example, 'Dog' is a class, while 'my_dog = Dog("Rex", "Labrador")' creates an object. You can make many objects from one class, each with different attribute values.
What does 'self' mean in Python class methods?
'Self' refers to the specific object the method is being called on. It allows the method to access that object's own attributes. When you write 'self.name', you are reading the 'name' attribute belonging to that particular instance, not some shared or global variable. Every instance method receives 'self' as its first argument.
Why is object-oriented programming useful?
OOP groups related data and behavior together, making large programs easier to organize, read, and maintain. Instead of tracking dozens of separate variables, you bundle them into objects. This structure mirrors how we naturally think about the world in categories and instances, which makes programs more intuitive to design and extend.
How does active learning help students grasp OOP concepts?
OOP requires students to build a mental model of blueprints and instances before they write code. Collaborative design activities, where students argue over which attributes belong in a class, make this abstract process social and visible. Students who design classes on paper first make far fewer conceptual errors when they translate that design into code.