Skip to content
Computer Science · Grade 11 · Object-Oriented Programming and Design · Term 2

Introduction to Object-Oriented Programming (OOP)

Students will understand the fundamental concepts of OOP: objects, classes, and instances, and their role in modeling real-world entities.

Ontario Curriculum ExpectationsCS.HS.P.1CS.HS.P.2

About This Topic

Object-oriented programming introduces students to classes as blueprints for creating objects, which represent real-world entities with attributes and behaviors. In this topic, students explore how a class defines properties like a car's color and methods like accelerating, while objects are specific instances such as a red sports car. This approach aligns with Ontario's Grade 11 Computer Science curriculum, addressing standards CS.HS.P.1 and CS.HS.P.2 by emphasizing software design principles.

Students compare OOP to procedural programming, noting benefits like modularity, reusability, and easier maintenance through encapsulation and inheritance. Key questions guide them to differentiate classes from objects and construct simple classes, fostering skills in modeling complex systems. For example, they might design a Student class with attributes for name and grade, and a method to calculate averages.

Active learning shines here because students actively code, test, and refactor classes in real-time. Pair programming reveals design flaws quickly, while group critiques build peer feedback skills. These hands-on tasks turn abstract concepts into working programs, boosting retention and confidence in software development.

Key Questions

  1. Explain the benefits of an object-oriented approach over procedural programming.
  2. Differentiate between a class and an object in software design.
  3. Construct a simple class to represent a real-world entity, identifying its attributes and behaviors.

Learning Objectives

  • Compare the benefits of object-oriented programming (OOP) with procedural programming, citing modularity and reusability.
  • Differentiate between a class definition and an object instance, providing examples of each.
  • Construct a simple class in Python to model a real-world entity, identifying its essential attributes and behaviors.
  • Analyze the relationship between a class and its objects, explaining how objects inherit properties from their class.
  • Evaluate the suitability of OOP for modeling complex systems based on its core principles.

Before You Start

Introduction to Programming Concepts (Variables, Data Types, Control Structures)

Why: Students need a foundational understanding of how to declare variables, use basic data types, and implement conditional statements and loops before they can define attributes and methods within classes.

Functions and Procedures

Why: The concept of methods in OOP is an extension of functions. Students must be familiar with defining and calling functions to grasp how methods operate within a class.

Key Vocabulary

ClassA blueprint or template for creating objects. It defines the properties (attributes) and actions (methods) that all objects of that type will have.
ObjectAn instance of a class. It is a concrete entity created from the class blueprint, with its own specific values for attributes.
AttributeA data member or variable that stores the state or characteristics of an object. For example, a 'color' attribute for a Car object.
MethodA function or procedure associated with a class that defines the behavior or actions an object can perform. For example, an 'accelerate' method for a Car object.
InstanceSynonymous with 'object', referring to a specific realization of a class that exists in memory during program execution.

Watch Out for These Misconceptions

Common MisconceptionA class is the same as an object.

What to Teach Instead

A class serves as a template, while objects are instances created from it. Hands-on creation of multiple objects from one class, like several Dog instances, clarifies this through visible differences in attributes. Group discussions of code outputs reinforce the blueprint analogy.

Common MisconceptionOOP methods are just standalone functions.

What to Teach Instead

Methods belong to classes and access object-specific data via 'self' or 'this'. Pair coding exercises where students call methods on different instances show data encapsulation in action. Peer reviews highlight errors from treating methods as global functions.

Common MisconceptionOOP is only useful for large programs.

What to Teach Instead

Even simple programs benefit from OOP's organization. Small group projects building modular classes demonstrate reusability early. Comparing refactored procedural code to OOP versions reveals maintainability gains through collaborative testing.

Active Learning Ideas

See all activities

Real-World Connections

  • Video game development heavily relies on OOP to model characters, items, and game environments. For instance, a 'Player' class might define attributes like health and score, and methods like 'jump' or 'attack', with each player in the game being a unique object instance.
  • Software engineers at companies like Google use OOP principles to build complex applications such as operating systems and web browsers. They create classes for user interface elements, data structures, and system processes, making large codebases manageable and reusable.

Assessment Ideas

Quick Check

Present students with a scenario, such as a 'Book' in a library. Ask them to list 3 attributes (e.g., title, author, ISBN) and 2 methods (e.g., 'borrow', 'return') for a Book class. Then, ask them to create one specific 'Book' object with sample values.

Discussion Prompt

Facilitate a class discussion using the prompt: 'Imagine you are designing software for a school. What are some real-world entities you would model as classes? For one of these classes, identify its key attributes and behaviors, and explain why an object-oriented approach is beneficial here compared to a procedural one.'

Exit Ticket

Provide students with a simple Python code snippet defining a class (e.g., a 'Dog' class with 'name' and 'breed' attributes). Ask them to write down: 1. What is the name of the class? 2. What are the attributes defined? 3. Write one line of code to create an object (instance) of this class.

Frequently Asked Questions

What are the main benefits of OOP over procedural programming for Grade 11 students?
OOP promotes modularity by grouping data and behaviors, making code reusable and easier to maintain. Students see this when refactoring procedural scripts into classes, reducing errors in larger projects. Encapsulation protects data, while inheritance avoids repetition, skills vital for Ontario curriculum standards.
How do you differentiate a class from an object in teaching OOP?
Explain classes as blueprints defining structure, objects as built items with unique values. Use analogies like cookie cutters versus cookies. Students construct and instantiate classes in code, observing how one class yields varied objects, solidifying the distinction through direct manipulation.
How can active learning help teach OOP concepts effectively?
Active approaches like pair programming and group class design make abstract ideas concrete as students code, test, and iterate live. Collaborative debugging uncovers flaws faster than lectures, while presenting designs builds communication. These methods align with student-centered pedagogy, improving engagement and deep understanding of classes and objects.
What real-world examples work best for introducing OOP classes?
Use familiar entities like vehicles, with Car class for attributes (speed, fuel) and methods (drive, refuel). Students relate to daily items, then extend to school contexts like Course or Student. Hands-on modeling transitions smoothly to code, enhancing relevance and retention in computer science.