Advanced Programming II – SS3 Digital Technologies Lesson Note (First Term)
Lesson note at a glance
- Class
- SS3
- Subject
- Digital Technologies
- Term
- First Term
- Reading time
- 5 min
Object-oriented programming (OOP) is a style of coding that groups data and actions together into objects, so that code mirrors the real world. A class is the template, and an object is an item created from that template.
Behavioural objectives
By the end of the lesson, students should be able to:
- Describe an object in terms of its properties and behaviours.
- Explain the difference between a class and an object.
- Explain encapsulation and give two reasons for using it.
- Explain inheritance using the terms superclass and subclass.
- Explain polymorphism with an example.
What is object-oriented programming?
Object-oriented programming is a style of coding where data and actions are grouped together into objects, so that programs are easier to manage.
What is procedural programming?
Procedural programming is a style of coding that gives the computer a list of instructions to follow from top to bottom.
- Procedural code: a long list of steps, with data and functions kept apart.
- Object-oriented code: small units called objects, each holding its own data and actions.
The real world does not work like a list. It is made up of objects.
| Feature | Procedural programming | Object-oriented programming |
|---|---|---|
| Main unit | Function or step | Object |
| Data and actions | Kept separate | Grouped together |
| Best for | Short, simple programs | Large, complex programs |
| Code reuse | Limited | Easy, through inheritance |
What are the parts of an object?
An object has two parts: properties (what it is) and behaviours (what it does).
- Properties: the data that describes the object. They are also called attributes. Examples are colour, battery percentage and screen size.
- Behaviours: the actions the object can perform. In code they are written as methods (functions inside a class). Examples are making a call, sending a text and taking a photo.
| Object | Properties | Behaviours |
|---|---|---|
| Phone | Colour, battery percentage, screen size | Make a call, send a text, take a photo |
| Bicycle | Colour, number of gears | Pedal, brake, ring the bell |
What is the difference between a class and an object?
A class is a blueprint that describes an object, and an object is one real item built from that blueprint.
- Class: the template. It lists the properties and behaviours that every item of that kind will have.
- Object: an item created from the class. It is also called an instance.
The house example
- The class is the drawing: it describes what a house should look like, but you cannot sleep in it.
- The objects are the houses: if you build 10 houses on a street from that drawing, each house is an object.
- Different details: one house can be blue and another red, but both follow the same blueprint.
| Point | Class | Object |
|---|---|---|
| Meaning | Template or blueprint | Item made from the template |
| Number needed | Written once | As many as you want |
| Real-world example | House drawing | A finished house |
| Phone example | Phone (colour, battery, call) | A black phone with 80% battery |
What is encapsulation?
Encapsulation is the wrapping of data and methods inside a class, while hiding the inner workings from the user.
- Microwave example: you press a button to heat food. You do not need to know how the microwave makes heat.
- In code: the class is the “capsule”. It hides its complicated parts and shows only the methods the user needs.
- Bank account example: the balance is hidden. You change it only through methods such as deposit and withdraw.
Why use encapsulation?
- Safety: it prevents people from accidentally changing important data.
- Simplicity: it makes code easier to use, because you see only what is necessary.
What is inheritance?
Inheritance is the process by which one class receives the properties and methods of another class.
- Real-world idea: children inherit traits from their parents.
- Code idea: a Car, a Truck and a Motorcycle can all inherit from a Vehicle class.
- Shared properties: Vehicle holds Speed and Fuel, so the three subclasses do not repeat them.
What are a superclass and a subclass?
- Superclass (parent): holds the general information. All vehicles move.
- Subclass (child): inherits from the superclass and adds its own details. A car has a boot, and a motorcycle has a kickstand.
What are the benefits of inheritance?
- Less typing: shared code is written once, in the superclass.
- Easy updates: a change in the superclass reaches every subclass.
- Clear structure: classes are arranged from general to specific.
What is polymorphism?
Polymorphism means “many shapes”: the same method name can perform different actions for different objects.
Think of the command “Speak.” The command is the same, but the result depends on who is doing the action.
| Object | Command | Result |
|---|---|---|
| Dog | Speak | “Woof” |
| Cat | Speak | “Meow” |
| Human | Speak | “Hello” |
How does polymorphism work in code?
- Each class has a method with the same name, for example make_sound().
- Each class writes its own version of that method. This is called method overriding.
- A list of different animal objects is created.
- The program calls make_sound() on every object in the list.
- Each object runs its own version, so the dog barks and the cat meows.
Why do programmers use object-oriented programming?
Programmers use OOP because it makes large programs easier to build, read and change.
- Real-world model: objects match things people already understand.
- Reuse: inheritance lets one class serve many others.
- Safety: encapsulation protects data from accidental change.
- Flexibility: polymorphism lets one command work on many kinds of object.
What are the key terms in object-oriented programming?
- Class: the template or blueprint.
- Object: the actual item created from the template, also called an instance.
- Property: a piece of data that describes an object.
- Method: an action an object can perform.
- Encapsulation: hiding the inner workings for safety and simplicity.
- Inheritance: sharing code between a parent (superclass) and a child (subclass).
- Polymorphism: one action performing differently depending on the object.
Evaluation
- What two things does an object have? Give one example of each for a phone.
- Explain the difference between a class and an object using the blueprint and house example.
- What is encapsulation? State two reasons for using it.
- In the Vehicle example, which is the superclass and which are the subclasses?
- What does polymorphism mean? Give an example using the command “Speak.”
Assignment
Choose a real-world item other than a phone (for example, a bicycle or a television). List two properties and two behaviours of the item. Then explain in two or three sentences how you would describe it as a class and one object created from that class.
This term's Digital Technologies topics
SS3 First Term · 7 topics

