← ACARA Digital Technologies Years 9–10

Why programmers use object-oriented programming

Object-oriented programming: building a program from objects that bundle related data with the code that uses it, modelling real things and reusing a blueprint.

Understanding Why programmers use object-oriented programming in ACARA Digital Technologies Years 9–10

What it does: The Pet class models a real pet by keeping its data (name, energy) and its action (eat) together in one place. Both objects come from the same Pet class, so the code is written once and reused for each new pet. OOP models real things by grouping what a thing has (properties) and what it can do (methods). One class means you fix or improve the code in a single place instead of 50. OOP is mainly about organisation. Keeping related code together makes big programs easier to manage, not automatically faster. The class bundles the name property and the greet method inside one structure.

Common mistakes: The special setup method must be spelled constructor. A misspelling means it is just an ordinary method, so it never runs when a Dog is created. Correct line: constructor(name) {. Without this, the line just assigns the parameter to itself and the object stores nothing. To keep data inside the object, write this.name = name;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 728–742) and word search (Modules 710–742).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does object-oriented programming bundle together inside an object?
Related data and the code that uses itOnly a list of numbers
Matches
let petName = 'Rex'; let petEnergy = 5; let petName2 = 'Mia'; let petEnergy2 = 8;
↓
Related data is stored in loose separate variables, so it is not kept together and gets messy as the program grows. Use a Pet class and make one object per pet.
Applying
Meanings
Term
OOP
Meaning
Object-oriented programming: building a program from objects that bundle related data with the code that uses it, modelling real things and reusing a blueprint.
Practice
class Player {
Testing
Gaps
Player {
Check Answer
Spots
1class Dog {
2 constructer(name) {

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Horned Lizard' badge — Bug Squasher, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does object-oriented programming bundle together inside an object?
A. Related data and the code that uses it ✓
B. Only a list of numbers
An object keeps its data (properties) and the code that works on it (methods) together in one place.
2. Which is a good way to model a real-world pet in OOP?
A. Separate unrelated variables scattered across the file
B. An object with name and age properties and a speak() method ✓
OOP models real things by grouping what a thing has (properties) and what it can do (methods).
3. Why do programmers write a class?
A. To reuse one blueprint to make many objects ✓
B. To make each object from scratch every time
A class is a blueprint. You write it once and use new to make as many objects as you need.
4. A game has 50 enemies that all behave the same way. What is the OOP approach?
A. Copy and paste the same code 50 times
B. Write one Enemy class and create 50 objects ✓
One class means you fix or improve the code in a single place instead of 50.
5. How does keeping related code together help in a large program?
A. It is easier to find, understand and fix the code for one thing ✓
B. It makes the program run faster on every computer
OOP is mainly about organisation. Keeping related code together makes big programs easier to manage, not automatically faster.

Match the Pairs

class Player { } → A blueprint that can be reused to make many player objects
const hero = new Player('Kai', 100); → Creates one object from the Player blueprint with its own data
Modelling a real-world thing: a pet has data (name, energy) and actions (eat) kept together in one object → class Pet { constructor(name) { this.name = name; this.energy = 5; } eat() { this.energy++; } }
Reusing a blueprint: one class makes many objects, so you do not rewrite the same code → const a = new Pet('Rex'); const b = new Pet('Mia');
let petName = 'Rex'; let petEnergy = 5; let petName2 = 'Mia'; let petEnergy2 = 8; → Related data is stored in loose separate variables, so it is not kept together and gets messy as the program grows. Use a Pet class and make one object per pet.
function feedPet(name, energy) { return energy + 1; } // copied again as feedDog, feedCat... → The same code is copied for each kind of thing instead of reusing a blueprint. Put the behaviour in a class method so every object can use it.

Key Term

OOP
Object-oriented programming: building a program from objects that bundle related data with the code that uses it, modelling real things and reusing a blueprint.

Fill in the Blanks

1. class Player { constructor(name) { this.name = name; } }
Hint: Type the keyword that declares a reusable blueprint for objects
2. const a = new Player("Ava"); const b = new Player("Liam");
Hint: Type the keyword that builds an object from the blueprint
3. class Car { constructor(speed) { this.speed = speed; } }
Hint: Type the keyword that refers to the object being created, so data stays bundled with it
4. class Pet { constructor(name) { this.name = name; } }
Hint: Type the special method name that sets up each new object's data
5. const ava = new Player("Ava"); ava.points = 0; console.log(ava.points);
Hint: Type the property name that was stored on the object in the line above

Spot the Error

Question 1
A class Dog {
B constructer(name) {
C this.name = name;
D }
E }
Line B — The special setup method must be spelled constructor. A misspelling means it is just an ordinary method, so it never runs when a Dog is created. Correct line: constructor(name) {
Question 2
A class Player {
B constructor(name) {
C name = name;
D this.score = 0;
E }
F }
Line C — Without this, the line just assigns the parameter to itself and the object stores nothing. To keep data inside the object, write this.name = name;
Question 3
A class Car {
B speedUp() {
C this.speed + 10;
D }
E }
Line C — A plain + calculates a value but does not store it. To change the car's own data inside its method, use +=, like this.speed += 10;
Question 4
A Class Student {
B constructor(name) {
C this.name = name;
D }
E }
Line A — The keyword class must be all lowercase because JavaScript is case-sensitive. A class is the blueprint, so it must start with class Student {
Question 5
A class Pet {}
B const a = new Pet();
C const b = new Pet();
D const c = Pet();
Line D — Each object made from the blueprint needs the new keyword. Without it, JavaScript throws an error. Correct line: const c = new Pet();

Student with a class code? Join your class →