Skip to content
Computer Science · 12th Grade

Active learning ideas

Inheritance and Polymorphism in Depth

Active learning works for inheritance and polymorphism because these concepts require students to see relationships between classes rather than just memorize definitions. When students design, code, and critique their own hierarchies, they confront misconceptions directly and build lasting mental models that lectures alone cannot provide.

Common Core State StandardsCSTA: 3B-AP-14CSTA: 3B-AP-15
25–50 minPairs → Whole Class4 activities

Activity 01

Project-Based Learning50 min · Small Groups

Collaborative Design: Model the School

Student groups design a class hierarchy for a school management system with students, teachers, staff, and administrators. Each group must identify at least two levels of inheritance, define a shared interface, and justify every inheritance decision using the 'is-a' relationship test. Groups present their UML diagrams and critique each other's design choices, with the teacher guiding discussion toward composition alternatives where inheritance was overused.

Compare the trade-offs between composition and inheritance in software design.

Facilitation TipDuring Collaborative Design: Model the School, circulate and ask each group to explain why they placed a method in the parent class versus a child class, forcing justification of design choices.

What to look forPresent students with two scenarios: one where inheritance is clearly appropriate (e.g., different types of vehicles inheriting from a 'Vehicle' class) and one where composition is better (e.g., a 'Car' class having an 'Engine' object). Ask students to write 1-2 sentences explaining why each design choice is suitable for its respective scenario.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

Activity 02

Think-Pair-Share25 min · Pairs

Think-Pair-Share: Composition vs. Inheritance

Provide students with 6 short design scenarios and ask them to individually judge whether each should use inheritance or composition. Pairs then compare their answers and must reach consensus, articulating the decision rule they applied. The most contested examples get shared with the class for full discussion, focusing on scenarios where both seem valid.

Explain how polymorphism simplifies the management of diverse object types through a common interface.

Facilitation TipDuring Think-Pair-Share: Composition vs. Inheritance, provide a concrete code snippet with both approaches to ground the abstract comparison in visible differences.

What to look forFacilitate a class discussion using the prompt: 'Imagine you are building a system to manage different types of shapes (Circle, Square, Triangle). How would you use inheritance and polymorphism to allow a function to calculate the area of any shape in a collection? What are the benefits of this approach compared to having separate functions for each shape?'

UnderstandApplyAnalyzeSelf-AwarenessRelationship Skills
Generate Complete Lesson

Activity 03

Project-Based Learning45 min · Pairs

Collaborative Lab: Polymorphism in Action

Students implement a Shape parent class and Circle, Rectangle, and Triangle subclasses, each overriding an area() method. They then write a loop that calls area() on a mixed list of shapes and verify the results. Pairs then add a new shape subclass to confirm the loop works without any modification, directly demonstrating how polymorphism supports extensibility.

Design a class structure that effectively leverages inheritance and polymorphism for extensibility.

Facilitation TipDuring Collaborative Lab: Polymorphism in Action, require students to run the same method call on different objects and predict the output before executing, making runtime behavior tangible.

What to look forStudents work in pairs to design a simple class hierarchy for a library system (e.g., Book, DVD, Magazine inheriting from Item). They then swap their designs and use a checklist to assess: 1. Is there clear code reuse via inheritance? 2. Does polymorphism simplify managing different item types? 3. Are abstract classes or interfaces used effectively? Partners provide one constructive suggestion for improvement.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

Activity 04

Gallery Walk40 min · Pairs

Gallery Walk: Class Hierarchy Critiques

Each student or pair designs a class hierarchy poster for an assigned domain such as vehicles, animals, banking, or electronics. Post them around the room and have students rotate, leaving sticky-note critiques at each station that identify one strength and one potential design flaw. The original designers respond to the critiques in a brief class discussion, defending or reconsidering their choices.

Compare the trade-offs between composition and inheritance in software design.

Facilitation TipDuring Gallery Walk: Class Hierarchy Critiques, post a clear rubric so observers know exactly what to evaluate rather than relying on vague impressions.

What to look forPresent students with two scenarios: one where inheritance is clearly appropriate (e.g., different types of vehicles inheriting from a 'Vehicle' class) and one where composition is better (e.g., a 'Car' class having an 'Engine' object). Ask students to write 1-2 sentences explaining why each design choice is suitable for its respective scenario.

UnderstandApplyAnalyzeCreateRelationship SkillsSocial Awareness
Generate Complete Lesson

A few notes on teaching this unit

Teachers should emphasize that inheritance and polymorphism are tools for managing complexity, not goals in themselves. Avoid letting students over-inherit just to share code, as this tightens coupling unnecessarily. Research shows that students grasp overriding best when they see concrete before-and-after behavior, so code execution is more effective than slides alone. Spend time on why polymorphism matters: it lets systems grow without rewriting existing code, which is the heart of maintainable software.

Successful learning looks like students confidently designing class hierarchies where shared code is purposeful, method overriding is intentional, and polymorphism simplifies complex systems. They should explain why they chose inheritance over composition and how polymorphism allows one method call to behave differently across objects.


Watch Out for These Misconceptions

  • During Think-Pair-Share: Composition vs. Inheritance, watch for students assuming inheritance is always the best way to share code.

    Provide an over-inherited class hierarchy for a school system where every class inherits from a generic 'SchoolMember' class. Have students refactor it to use composition (e.g., a 'Teacher' class containing a 'Role' object) and compare the modularity in their new design.

  • During Collaborative Lab: Polymorphism in Action, watch for students believing a subclass can use all parent methods exactly as defined.

    Include a parent class with an abstract method and a parent method marked final in the lab materials. Have students attempt to override the final method and see the compiler error, then implement the abstract method in child classes to observe required behavior.

  • During Gallery Walk: Class Hierarchy Critiques, watch for students thinking polymorphism only refers to method overriding.

    Ask groups to identify examples of method overloading in their hierarchies (e.g., multiple constructors) and explain how these differ from overriding. During the walk, highlight these examples in peer feedback.


Methods used in this brief