The First Steps to Object-Oriented Programming

By: zigmoid
Posted on: 07/17/2025

1. First of first what is Programming Anyway?

Before we jump into OOPs, let’s roll back. what is programming?
Programming is basically telling computers what to do, step by step.
You write instructions → computer follows → magic happens.

Imagine you’re baking a cake: that have these steps

  1. Get ingredients
  2. Mix stuff
  3. Bake it
  4. Eat it 😋

A program is the same: you give it steps.


🔥 2. The Two Big Styles of Programming

When you start learning to code, you usually start with Procedural Programming.
In this style, you write instructions one after another — like a recipe.

Example: C, early BASIC, old-school Pascal.

But when programs get bigger, it’s like trying to run a school with just sticky notes — total chaos.

So, smart nerds invented Object-Oriented Programming (OOP).
It’s a style where you organize code around objects, not just steps.


🎭 3. Why OOP is Like Real Life

OOP is genius because it copies how we think about real things.

  • Objects: Everything around you is an object — your phone, your dog, your math textbook.
  • Properties: What it has — your phone’s color, your dog’s name.
  • Behaviors: What it does — your phone rings, your dog barks.

🏗️ 4. Core OOP Concepts

Alright, here comes the meat. OOP has four main pillars — like legs on a table. If one is missing, your program wobbles and falls on its face.


🧩 4.1 Classes and Objects

Class → the blueprint.
Object → the thing made from the blueprint.

Think:

  • Class: Car design
  • Object: Your actual red Toyota
javaCopy codeclass Car {
    String color;
    String brand;
    void drive() {
        System.out.println("Car is driving");
    }
}

Here’s what’s happening:

  • Car is a class. It knows a car’s color, brand, and how to drive().
  • When you want a car: you create an object.
javaCopy codeCar myCar = new Car();
myCar.color = "Blue";
myCar.brand = "Honda";
myCar.drive();

So now you have a real car to drive — not just an idea.


🧑‍🏫 Real Life Analogy

Think of your class teacher:

  • Class: The teacher’s lesson plan.
  • Object: The actual lesson she teaches you today.

🔐 4.2 Encapsulation

Long word, easy idea: Wrap data and code together, and hide the messy stuff.

Why?

  • Keeps your code neat.
  • Stops people from messing with stuff they shouldn’t.

Example: A bank account

You don’t want anyone changing your money directly!

javaCopy codeclass BankAccount {
    private double balance;

    public void deposit(double amount) {
        balance += amount;
    }

    public void withdraw(double amount) {
        if (amount <= balance) {
            balance -= amount;
        } else {
            System.out.println("Not enough money!");
        }
    }

    public double getBalance() {
        return balance;
    }
}

Here:

  • balance is private — can’t touch it directly.
  • deposit, withdraw, getBalance — safe ways to interact.

🧑‍🏫 Real Life Analogy

Think of a medicine capsule — the powder is hidden inside.
You swallow the capsule, not raw powder — that’s encapsulation.


👨‍👩‍👧 4.3 Inheritance

This one’s simple — kids inherit traits from parents.

In OOP:

  • A class (child) can use stuff from another class (parent).

Example:

javaCopy codeclass Animal {
    void sleep() {
        System.out.println("Sleeping...");
    }
}

class Dog extends Animal {
    void bark() {
        System.out.println("Woof woof!");
    }
}

Dog myDog = new Dog();
myDog.sleep(); // from Animal
myDog.bark();  // from Dog

Dog didn’t write sleep() — it inherited it from Animal.


🧑‍🏫 Real Life Analogy

You inherit your mom’s eyes, your dad’s nose. Same idea!


🧙 4.4 Polymorphism

Scary word. Fun idea.
Poly = many
Morphism = forms

One thing, many forms.


Example:

Let’s say you have a Printer class.
Different printers print differently.

javaCopy codeclass Printer {
    void print() {
        System.out.println("Printing something...");
    }
}

class InkjetPrinter extends Printer {
    void print() {
        System.out.println("Inkjet printer printing...");
    }
}

class LaserPrinter extends Printer {
    void print() {
        System.out.println("Laser printer printing...");
    }
}

Here:

  • Same print() method.
  • But each printer does it its own way.

🧑‍🏫 Real Life Analogy

Think of the word “play”:

  • Play football
  • Play guitar
  • Play a movie

Same word — different actions.


⚙️ 5. More OOP Concepts (Advanced, but Chill)

If you wanna flex harder, here are a few more buzzwords:


Abstraction

Hide the complex stuff, show only what’s needed.

Example: When you drive a car, you just use the wheel and pedals. You don’t see the engine’s madness.

In code:

javaCopy codeabstract class Shape {
    abstract void draw();
}

class Circle extends Shape {
    void draw() {
        System.out.println("Drawing circle");
    }
}

Shape says “Hey, every shape must draw itself!”
But doesn’t say how. That’s left to Circle.


🚀 Interface

An interface is like a promise: “I will do this!”

Example:

javaCopy codeinterface Animal {
    void eat();
}

class Cow implements Animal {
    public void eat() {
        System.out.println("Cow is eating grass");
    }
}

🎨 6. Real World OOP Example: A School

Let’s build a whole mini-OOP world for a school.


🎒 Classes

  • Student
  • Teacher
  • Classroom

Each has properties and methods.

javaCopy codeclass Student {
    String name;
    int rollNumber;

    void study() {
        System.out.println(name + " is studying");
    }
}

class Teacher {
    String name;
    String subject;

    void teach() {
        System.out.println(name + " is teaching " + subject);
    }
}

class Classroom {
    Student student;
    Teacher teacher;

    void conductClass() {
        teacher.teach();
        student.study();
    }
}

👩‍🏫 Objects

javaCopy codeStudent s1 = new Student();
s1.name = "Aditi";
s1.rollNumber = 23;

Teacher t1 = new Teacher();
t1.name = "Mr. Sharma";
t1.subject = "Math";

Classroom c1 = new Classroom();
c1.student = s1;
c1.teacher = t1;

c1.conductClass();

Boom.
A Student studies, a Teacher teaches — all in a Classroom.


🧰 7. Why OOP is Useful

When your code grows, OOP keeps it tidy.

  • Reusability: Write once, reuse everywhere.
  • Security: Hide what should be hidden.
  • Easy to update: Want all Dogs to have a new trick? Add it once.
  • Teamwork: Many devs can work on different parts without fighting.

8. Some Popular OOP Languages

  • Java: The OOP king for students.
  • C++: Old but gold.
  • Python: Simple syntax, very student-friendly.
  • C#: For Microsoft fans.
  • Ruby, PHP: Also use OOP a lot.

🧑‍💻 9. OOP in Daily Life

  • Mobile apps? OOP.
  • Games? OOP.
  • School management software? OOP.
  • Even the software in your smartwatch? Probably OOP.

📝 10. How to Learn OOP Well

Here’s how to become a mini OOP wizard:

  1. Start Small — Make simple classes and objects.
  2. Play with Inheritance — Create parent-child relationships.
  3. Encapsulation Practice — Use private and public.
  4. Polymorphism Fun — Override methods.
  5. Projects — Build small stuff: Calculator, Library, School System.
  6. Ask for Help — Teachers, seniors, ChatGPT (hi 👋).

🎯 11. Final Words

OOP is not just another boring chapter in your CS book — it’s how real software is built.

Key Takeaway:

  • Organize stuff like real life.
  • Wrap code and data together.
  • Reuse and extend without mess.
  • Code is clean, safe, and powerful.

🎉 Congrats, you know OOP now!

If you stuck around till here — hats off!
Go flex to your friends:

“Hey, I know Encapsulation, Inheritance, Polymorphism — do you?”


✏️ Your Turn

Try this:

  • Make a Bike class.
  • Add color, brand, and a ride() method.
  • Create 2 different bikes (objects) and make them ride.

Trust me, you’ll get it.
And if you get stuck, just poke me — I’m right here in your pocket.


📌 Glossary

WordMeaning
ClassBlueprint for objects
ObjectReal thing from the class
EncapsulationWrapping data + code, hiding unnecessary parts
InheritanceGetting properties and behaviors from a parent class
PolymorphismSame thing, different forms
AbstractionShowing only necessary parts
InterfacePromise to do something

🚀 Keep Coding, Keep Crushing

You’re now officially more OOP than most grown-ups pretending to know it.
Go build stuff, break stuff, and fix it again.

Stay curious, stay coding!