Coding · Grade 10
Objects, Classes and Encapsulation
Using a makerspace tool library, learners design classes that start valid, act through well-named methods and print readably with __str__. They protect data with encapsulation (underscore conventions and validating properties), distinguish class and instance attributes and identity from equality, and build classes from others with composition (has-a) and inheritance (is-a), including overriding and polymorphism.
- 4 lessons
- About 95 minutes
- Check what you learned: 8 questions
- Ways to answer: choose an answer, put code in order, trace code, match pairs, type a number and sort into groups
What learners will discover
- Design classes with __init__, methods that return results and a readable __str__.
- Encapsulate data with internal attributes and validating properties so invariants are preserved.
- Distinguish class attributes from instance attributes, and identity (is) from equality (== and __eq__).
- Use composition and inheritance appropriately, including overriding, super() and polymorphism.
Lessons
-
Designing classes 5 steps2 practiceabout 20 min
-
Encapsulation 6 steps4 practiceabout 24 min
-
Class attributes, identity and equality 4 steps2 practiceabout 20 min
-
Composition and inheritance 5 steps3 practiceabout 22 min
-
Check what you learned 8 questions at the end
Keep exploring
More 10th grade coding
- 10th Grade Coding Worksheets11 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read