Hello, future programmer! Have you ever wondered how video games create characters? How does a game know that a car has wheels, a colour, and can move? How does a banking app know that a customer has a name, an account number, and a balance? The answer is something called Object Oriented Programming, or OOP for short.
OOP is a way of writing computer programs. Instead of writing a long list of instructions, you build your program out of objects. An object is like a small machine that has its own data and its own actions. You can create many objects from the same blueprint. Each object can be different, but they all work the same way.
In this module, you will learn the very basics of OOP. You will learn what objects are, what classes are, and why they are useful. We will use simple words and many examples. By the end, you will understand how programmers think when they use OOP. Let’s begin!
After you finish this module, you will be able to:
Chidi lived in Aba. His uncle owned a toy factory. One day, Chidi visited the factory. He saw something amazing. There was a big machine that made toy cars. The machine had a blueprint. Every time the machine ran, it made a new toy car. Each car was the same shape, but they were painted different colours.
Chidi asked his uncle, “How does the machine know what a car looks like?” His uncle smiled and showed him a large paper. On the paper was a drawing of a car. It showed that a car has four wheels, a body, and a roof. It also showed that a car can move forward and backward.
“This paper is the blueprint,” said his uncle. “The machine uses this blueprint to make as many cars as we want. Each car is an object. The blueprint is the class.”
Chidi was confused. “What do you mean by object and class?” he asked. His uncle picked up two toy cars. “These two cars are objects,” he said. “They were made from the same blueprint. But this one is red and that one is blue. They have different colours, but they both have four wheels and can move.”
Chidi understood. “So the blueprint is the class,” he said. “And each car is an object.” His uncle nodded. “That is exactly what Object Oriented Programming is. You write a class once. Then you can create many objects from it.”
Moral of the story: A class is a blueprint. An object is a thing made from that blueprint. You can make many objects from one class.
Definition: Programming is writing instructions for a computer to follow.
Why it is important: Computers cannot think for themselves. They need step-by-step instructions.
Simple explanation: Imagine you are telling a robot how to make a sandwich. You say: “Pick up the bread. Put butter on it. Put cheese on it. Close the bread.” That is programming.
Real-life example: A washing machine follows a program. You choose “Quick Wash” and it follows steps.
School example: A recipe for baking a cake is like a program. It has steps to follow.
Home example: Your morning routine is a program. You wake up, brush your teeth, eat breakfast, go to school.
Nigerian example: A recipe for jollof rice is a program. It tells you what to do step by step.
Illustration:
Start
|
V
Step 1: Wake up
|
V
Step 2: Brush teeth
|
V
Step 3: Eat breakfast
|
V
Step 4: Go to school
|
V
End
Mini summary: Programming is writing instructions for a computer. A program is a list of steps.
Definition: Object Oriented Programming (OOP) is a way of writing programs using objects.
Why it is important: OOP helps programmers organise their code. It makes programs easier to build, fix, and change.
Simple explanation: Instead of writing one long list of instructions, you create small building blocks called objects. Each object has its own data and its own actions.
Real-life example: A car is an object. It has data (colour, speed) and actions (drive, stop).
School example: A student is an object. They have data (name, age) and actions (study, play).
Home example: A dog is an object. It has data (name, breed) and actions (bark, run).
Nigerian example: A trader in the market is an object. They have data (name, goods) and actions (buy, sell).
Illustration:
+---------------------+ | OBJECT: Car | | Data: colour, speed| | Actions: drive, stop| +---------------------+
Mini summary: OOP uses objects. An object has data and actions. OOP makes programs easier to organise.
Definition: An object is a thing that has data and actions.
Why it is important: Objects are the building blocks of OOP. Everything in OOP is an object.
Simple explanation: Think of a phone. It has data (brand, colour, battery level) and actions (call, text, take photo). That is an object.
Real-life example: A football is an object. It has data (size, colour) and actions (bounce, roll).
School example: A book is an object. It has data (title, author, pages) and actions (open, close, read).
Home example: A fridge is an object. It has data (temperature, contents) and actions (cool, freeze).
Nigerian example: A danfo bus is an object. It has data (colour, route) and actions (move, stop).
Illustration:
+---------------------+ | OBJECT: Phone | | Data: brand, colour| | Actions: call, text| +---------------------+
Mini summary: An object is a thing with data and actions. Everything in OOP is an object.
Definition: A class is a blueprint for creating objects.
Why it is important: A class defines what data and actions an object will have.
Simple explanation: Think of a class as a cookie cutter. The cookie cutter is the class. The cookies are the objects. You can make many cookies from one cutter.
Real-life example: A house plan is a class. The houses built from it are objects.
School example: A uniform design is a class. Each student’s uniform is an object.
Home example: A recipe is a class. Each cake you bake is an object.
Nigerian example: A pattern for a dress is a class. Each dress sewn from it is an object.
Illustration:
Class: "Car"
|
V
+--------+ +--------+ +--------+
| Car 1 | | Car 2 | | Car 3 |
| Red | | Blue | | Green |
+--------+ +--------+ +--------+
Objects made from the class
Mini summary: A class is a blueprint. It defines what objects will look like.
Definition: A class is the blueprint. An object is the thing made from the blueprint.
Why it is important: This is the most important idea in OOP. If you understand this, you understand OOP.
Simple explanation: A class is like a plan for a house. An object is an actual house you can live in.
Real-life example: A car factory has a design for a car (class). The cars that roll off the line are objects.
School example: A teacher’s lesson plan is a class. Each lesson taught is an object.
Home example: A recipe for bread is a class. Each loaf you bake is an object.
Nigerian example: A design for ankara fabric is a class. Each piece of fabric is an object.
Table: Class vs Object
| Feature | Class | Object |
|---|---|---|
| What is it? | A blueprint | A thing made from the blueprint |
| How many? | One class | Many objects |
| Example | Car design | Your red car |
| Exists in memory? | No | Yes |
Illustration:
Class (Blueprint)
|
V
+---------+ +---------+ +---------+
| Object 1| | Object 2| | Object 3|
+---------+ +---------+ +---------+
Mini summary: A class is a blueprint. An object is a thing made from the blueprint. One class can make many objects.
Definition: Attributes are the data that an object holds. They describe what the object is like.
Why it is important: Attributes store information about an object.
Simple explanation: If the object is a student, the attributes are name, age, and class.
Real-life example: A phone has attributes: brand, colour, battery level.
School example: A student has attributes: name, age, grade.
Home example: A dog has attributes: name, breed, age.
Nigerian example: A market stall has attributes: owner name, goods sold, location.
Illustration:
+---------------------+ | OBJECT: Student | | Attributes: | | - name: "Ada" | | - age: 14 | | - grade: "JSS3" | +---------------------+
Mini summary: Attributes are the data of an object. They describe what the object is like.
Definition: Methods are the actions that an object can do.
Why it is important: Methods let objects do things. They make objects useful.
Simple explanation: If the object is a student, the methods are study, play, and sleep.
Real-life example: A phone has methods: call, text, take photo.
School example: A student has methods: study, write, read.
Home example: A dog has methods: bark, run, eat.
Nigerian example: A trader has methods: buy, sell, count money.
Illustration:
+---------------------+ | OBJECT: Student | | Methods: | | - study() | | - play() | | - sleep() | +---------------------+
Mini summary: Methods are the actions of an object. They let objects do things.
Definition: An object has both attributes (data) and methods (actions).
Why it is important: This is what makes an object complete.
Simple explanation: Think of a car. Attributes: colour, speed. Methods: drive, stop.
Real-life example: A bank account has attributes: account number, balance. Methods: deposit, withdraw.
School example: A student has attributes: name, age. Methods: study, take exam.
Home example: A fridge has attributes: temperature. Methods: cool, defrost.
Nigerian example: A danfo bus has attributes: route, fare. Methods: pick passengers, drop passengers.
Illustration:
+---------------------+ | OBJECT: Car | | Attributes: | | - colour: "red" | | - speed: 60 | | Methods: | | - drive() | | - stop() | +---------------------+
Mini summary: An object has both attributes and methods. Attributes are data. Methods are actions.
Definition: Creating a class means deciding what attributes and methods the objects will have.
Why it is important: You need to plan before you write code.
Simple explanation: Think of a class called “Student”. What data does a student have? Name, age, grade. What can a student do? Study, play, sleep.
Real-life example: A class called “Phone”. Attributes: brand, colour. Methods: call, text.
School example: A class called “Teacher”. Attributes: name, subject. Methods: teach, mark.
Home example: A class called “Pet”. Attributes: name, type. Methods: eat, sleep.
Nigerian example: A class called “Trader”. Attributes: name, goods. Methods: buy, sell.
Illustration:
Class: Student
|
V
Attributes: name, age, grade
Methods: study, play, sleep
Mini summary: Creating a class means deciding its attributes and methods.
Definition: Creating an object means making a specific thing from a class.
Why it is important: Objects are what you use in your program.
Simple explanation: From the class “Student”, you create an object called “Ada”. Ada has name = “Ada”, age = 14, grade = “JSS3”.
Real-life example: From the class “Phone”, you create an object called “MyPhone”. It has brand = “Samsung”, colour = “blue”.
School example: From the class “Teacher”, you create an object called “MrBello”. He has subject = “Maths”.
Home example: From the class “Pet”, you create an object called “Bingo”. It has type = “dog”.
Nigerian example: From the class “Trader”, you create an object called “MamaNkechi”. She sells = “vegetables”.
Illustration:
Class: Student
|
V
Object: Ada
name = "Ada"
age = 14
grade = "JSS3"
Mini summary: Creating an object means making a specific thing from a class. You fill in the data.
Definition: OOP is useful because it helps organise code.
Why it is important: Organised code is easier to write, fix, and change.
Simple explanation: Imagine building a house with Lego blocks. Each block is an object. You can build anything by combining blocks. OOP is like Lego for programmers.
Real-life example: A car is made of many objects: engine, wheels, doors. Each object works on its own.
School example: A school is made of many objects: students, teachers, classrooms.
Home example: A kitchen is made of many objects: fridge, cooker, sink.
Nigerian example: A market is made of many objects: stalls, traders, customers.
Illustration:
+-------+ +-------+ +-------+
|Object | |Object | |Object |
+-------+ +-------+ +-------+
\ | /
\ | /
V V V
+-----------------+
| BIG PROGRAM |
+-----------------+
Mini summary: OOP is useful because it organises code. It makes programs easier to build and fix.
Definition: OOP is used in many real-world programs.
Why it is important: Knowing where OOP is used helps you understand why you are learning it.
Simple explanation: Video games use OOP. Banking apps use OOP. Social media uses OOP.
Real-life example: In a game, each character is an object. Each has health, speed, and actions.
School example: A school management system uses objects for students, teachers, and classes.
Home example: A smart home app uses objects for lights, fans, and doors.
Nigerian example: A bank app uses objects for customers, accounts, and transactions.
Illustration:
Video Game
|
V
+--------+ +--------+ +--------+
| Hero | | Enemy | | Weapon |
| health | | health | | damage |
| attack | | attack | | use |
+--------+ +--------+ +--------+
Mini summary: OOP is used in games, banking, social media, and many other programs.
Definition: There are other ways to program. OOP is one way.
Why it is important: Knowing the difference helps you understand why OOP is special.
Simple explanation: In older ways, you wrote a long list of steps. In OOP, you build objects that work together.
Real-life example: Old way: a recipe that says “do this, then this, then this”. OOP way: a team of chefs, each with their own job.
School example: Old way: one student does all the work. OOP way: a group project where each student has a role.
Home example: Old way: one person cooks everything. OOP way: family members each cook a dish.
Nigerian example: Old way: one trader sells everything. OOP way: a market with different stalls for different goods.
Table: OOP vs Procedural Programming
| Feature | Procedural | OOP |
|---|---|---|
| Organisation | Steps | Objects |
| Reuse | Hard | Easy |
| Fixing bugs | Hard | Easier |
| Best for | Simple tasks | Big programs |
Mini summary: OOP uses objects. Procedural uses steps. OOP is better for big programs.
Definition: Thinking in objects means looking at the world as a set of objects.
Why it is important: This is the first step to becoming an OOP programmer.
Simple explanation: When you see a car, think: what data does it have? What actions can it do?
Real-life example: When you see a phone, think: attributes (brand, colour), methods (call, text).
School example: When you see a student, think: attributes (name, age), methods (study, play).
Home example: When you see a dog, think: attributes (name, breed), methods (bark, run).
Nigerian example: When you see a danfo bus, think: attributes (route, fare), methods (move, stop).
Illustration:
See a thing
|
V
What data does it have? (Attributes)
|
V
What can it do? (Methods)
|
V
You are thinking in objects!
Mini summary: Thinking in objects means looking at things as having data and actions.
Definition: You have learned the basics of OOP.
Why it is important: Reviewing helps you remember.
Simple explanation: You learned what programming is, what OOP is, what objects and classes are, and how to think in objects.
Real-life example: Like finishing the first chapter of a book.
School example: Like finishing the first week of a new class.
Home example: Like learning to ride a bicycle for the first time.
Nigerian example: Like learning to make jollof rice for the first time.
Illustration:
Start → Learn Programming → Learn OOP → Learn Objects → Learn Classes → Ready for Module 2! 🎉
Mini summary: You know the basics of OOP. You are ready for Module Two.
| Word | Simple Definition |
|---|---|
| Programming | Writing instructions for a computer. |
| Object Oriented Programming | A way of programming using objects. |
| Object | A thing with data and actions. |
| Class | A blueprint for creating objects. |
| Attribute | Data that an object holds. |
| Method | An action that an object can do. |
| Blueprint | A plan or design. |
| Instance | Another word for an object made from a class. |
| Procedural | An older way of programming using steps. |
| Reuse | Using something again. |
| Organise | To arrange things neatly. |
Class (Blueprint)
|
V
Create Object
|
V
Fill in Attributes
|
V
Use Methods
|
V
Object Works! 🎉
1960s - Simula, first OOP language 1970s - Smalltalk 1980s - C++ 1990s - Java 2000s - Python, C# 2024 - You learn OOP!
| Feature | Class | Object |
|---|---|---|
| What is it? | A blueprint | A thing made from the blueprint |
| How many? | One class | Many objects |
| Example | Car design | Your red car |
| Exists in memory? | No | Yes |
| Feature | Attributes | Methods |
|---|---|---|
| What are they? | Data | Actions |
| Example (Student) | name, age | study, play |
| Example (Car) | colour, speed | drive, stop |
Lesson 1: Programming is writing instructions for a computer.
Lesson 2: OOP is a way of programming using objects.
Lesson 3: An object is a thing with data and actions.
Lesson 4: A class is a blueprint for creating objects.
Lesson 5: A class is a blueprint. An object is a thing made from the blueprint.
Lesson 6: Attributes are the data of an object.
Lesson 7: Methods are the actions of an object.
Lesson 8: An object has both attributes and methods.
Lesson 9: Creating a class means deciding its attributes and methods.
Lesson 10: Creating an object means making a specific thing from a class.
Lesson 11: OOP is useful because it organises code.
Lesson 12: OOP is used in games, banking, and social media.
Lesson 13: OOP uses objects. Procedural uses steps.
Lesson 14: Thinking in objects means looking at things as having data and actions.
Lesson 15: You reviewed and are ready for Module Two.
In this module, you learned what programming is and what Object Oriented Programming means. You discovered that an object is a thing with data and actions. You learned that a class is a blueprint for creating objects. You learned about attributes (data) and methods (actions). You learned the difference between a class and an object. You learned why OOP is useful and where it is used. You also learned to think in objects. You are now ready for Module Two, where you will learn how to create classes and objects in code.
Match the word to its meaning.
| Word | Meaning |
|---|---|
| 1. Object | A. Data that an object holds |
| 2. Class | B. A thing with data and actions |
| 3. Attribute | C. An action that an object can do |
| 4. Method | D. A blueprint for creating objects |
| 5. OOP | E. A way of programming using objects |
Answers: 1-B, 2-D, 3-A, 4-C, 5-E
Title: Think in Objects
Instructions: In groups of 3, choose a thing (e.g., a phone, a student, a dog, a bus). List its attributes and methods. Present to the class. Discuss: what data does it have? What can it do?
Title: My First Class in My Mind
Instructions: Think of a class called “MyPet”. Write down three attributes and three methods. Then create two objects from the class. Give each object different data. Write down what you created.
Title: Design a Class for Your School
Instructions: Choose something in your school (e.g., Student, Teacher, Classroom). Write down its attributes and methods. Create three objects from the class. Give each object different data. Present your design to the class.
Task: Write a short paragraph (5 sentences) explaining what you learned about OOP. Then, list three things you found easy and one thing you found hard. Finally, describe one class and one object you created in your mind.
In Module Two, we will learn about creating classes and objects in code. You will write your first class. You will create objects from it. You will use attributes and methods. To get ready, make sure you:
See you in Module Two! 🚀
End of Module One · Object Oriented Programming