Mock Teaching Session

Fundamentals of Object-Oriented Programming

Thinking in Objects, Not Just Code

10 Minute Presentation

Today, we shift from writing instructions line by line to designing software as a set of meaningful objects working together.

For the best interactive experience, view this presentation live at slides.qayyumri.xyz
01 / 13

Foundation

What is OOP?

OOP organizes software around objects: units that combine data with behavior.
Data What an object knows
Behavior What an object can do
Structure Easier to understand, reuse, and maintain
02 / 13

Core Idea

Everything Revolves Around Objects

A program becomes a collection of objects that represent real-world concepts and collaborate through behavior.

Program objects collaborate
Student register()
Course addTopic()
Lecturer teach()
Car drive()
03 / 13

Class and Object

Blueprint vs Instance

Class

Car

Blueprint or template for creating objects.

Objects

Actual cars

Myvi BMW Audi
class Car {
  constructor(brand) {
    this.brand = brand;
  }
}

const myCar = new Car("Myvi");
04 / 13

The Four Pillars

The Ideas That Shape OOP

Encapsulation

Protect state

Keep data and methods together behind controlled access.

Abstraction

Simplify use

Expose only what another object needs to know.

Inheritance

Reuse behavior

Build a child class from a parent class.

Polymorphism

Vary behavior

Use the same method name with different outcomes.

05 / 13

Encapsulation Analogy

The Car Hides Its Complexity

Engine Fuel injection Transmission Braking system
Steering Brake Accelerator Gear selector
As a driver

You do not directly manipulate the engine, fuel injection, or transmission. The manufacturer gives you safe controls.

06 / 13

Class Checkpoint

Drive the Object

Question for the class: which operation should be allowed to change the car's speed?

Car object
private int speed 0 km/h

Speed starts at 0. Choose one operation with the class.

07 / 13

Encapsulation in OOP

Public Controls, Private State

Engine private data / state
Accelerator pedal public method: accelerate()
Driver another object using the class
class Car {
  private int speed = 0;

  public void accelerate() {
    speed += 10;
  }
}
User cannot do car.speed = 500;
User must use car.accelerate();
08 / 13

Abstraction

Use the Interface, Not the Internal Details

Abstraction hides unnecessary internal details and shows only what the user needs.
Simple outside Clear actions like drive(), pay(), register()
Complex inside Implementation can change without changing usage
Better focus We teach the behavior before the mechanism
09 / 13

Two More Pillars

Inheritance & Polymorphism

Start with a shared parent idea, then let each child object respond in its own way.

Animal speak()
Dog barks
Cat meows
Inheritance Child classes reuse parent behavior.
Polymorphism Same method name, different behavior.
10 / 13

Code Example

Same Method, Different Output

class Animal {
  speak() {
    console.log("Animal makes a sound");
  }
}

class Dog extends Animal {
  speak() {
    console.log("Dog barks");
  }
}

class Cat extends Animal {
  speak() {
    console.log("Cat meows");
  }
}
new Dog().speak() Dog barks
new Cat().speak() Cat meows

The caller uses the same method name. The object decides the behavior.

11 / 13

Why It Matters

OOP Helps Programs Grow

Reusability Use proven classes again.
Maintainability Change one object at a time.
Scalability Add new types and behavior.
Testing Debug smaller units.
Modelling Map software to real domains.
12 / 13

Key Takeaways

Remember These Three Ideas

01

OOP designs software around objects.

02

Classes are blueprints; objects are real instances.

03

The four pillars help us write cleaner and reusable programs.

Thank you. Questions & Discussion
13 / 13