As your projects grow, you need a better way to structure your code — one that keeps it organised, reusable, and easy to manage. That’s where Object-Oriented Programming (OOP) comes in. OOP is a powerful style of programming that lets you group related data and functions into reusable building blocks called objects. In this section, you’ll learn the four key principles of OOP: creating objects, inheritance, polymorphism, and encapsulation.
L12: OOP – Classes and Objects
OOP starts with classes — blueprints for creating objects. A class defines what data (attributes) and behaviours (methods/functions) an object will have. You’ll learn how to define a class, create objects from it, and use them in your programs. This helps you model real-world things like players, cars, or enemies using code.
L13: Inheritance
Inheritance lets one class take on the properties and behaviours of another. For example, you might create a general Character class, and then have Warrior or Wizard classes inherit from it. This helps reduce repeated code and allows you to build more advanced systems with shared features.
L14: Polymorphism
Polymorphism means “many forms” — it allows different classes to use the same method name but behave in different ways. For example, different characters might all have a .speak() method, but each one says something different. You’ll learn how this makes your code more flexible and dynamic.
L15: Encapsulation
Encapsulation is about protecting the data inside your objects. You’ll learn how to control access to attributes and methods using visibility rules (like making things private or public), and why keeping parts of your code hidden helps prevent bugs and misuse.