chaidocs
YouTube

Why OOP

Hitesh Choudhary 10 pages 3 min read Updated Oct 12, 2026
On this page
  1. Why OOP?
  2. Procedural code works, **until it doesn't**
  3. What goes wrong at scale
  4. The problem is not writing code. It's **organising** code as it grows.
  5. Things that have **data** and can do actions
  6. Class vs **Object**
  7. A class is the **blueprint** of a house; objects are the houses built from it.
  8. Four practical problems, **solved**
  9. OOP in the **real world**
  10. Changing Code Is **Most** Of The Job

Introduction Chapter

Why OOP?

We need to feel the pain OOP was invented to fix.

A tired programmer slumped at a desk covered in sticky notes and tangled code, a Java mug beside the keyboard.
chaicode.com
Notes
Before we learn classes and objects, we need to feel the pain OOP was invented to fix. That pain shows up the moment a program grows.

Life Before OOP

Procedural code works, until it doesn't

  1. 01Loose dataData lives in loose variables; logic lives in separate functions.
  2. 02No guardsAny function can read or change any data.
  3. 03No ownershipAs the program grows, nobody knows who changed what.
chaicode.com
Notes
String student1Name = "Aman"; int student1Marks = 82; ... Kabir's marks = -40; nothing stops invalid data. static void printReport(String name, int marks) and updateMarks(String name, int marks) sit far from the data they touch. This is the shape of procedural code: data here, logic there, no connection enforced.

At Scale

What goes wrong at scale

The same loose structure that works for 3 students breaks at 10,000.

  • 10,000 students means 20,000 loose variables or messy parallel arrays.
  • Invalid data (negative marks) slips in because nothing guards it.
  • Changing one field means hunting through every function that touches it.
  • Ten developers working on this code will step on each other.
Ten developers crowded around one tangled whiteboard of code, each editing a different wire that leads to the same messy box.
chaicode.com
Notes
10,000 students means 20,000 loose variables or messy parallel arrays. Invalid data (negative marks) slips in because nothing guards it. Changing one field means hunting through every function that touches it. Ten developers working on this code will step on each other.

Key Idea

The problem is not writing code. It's organising code as it grows.
A developer staring up at a giant tangled ball of wires representing sprawling code.
chaicode.com
Notes
Key idea: the problem is not writing code. It's organising code as it grows.

What OOP Actually Is

Things that have data and can do actions

OOP organises code the way we already think about the world.

  • A car has data (colour, speed, fuel) and actions (start, brake, accelerate).
  • A bank account has data (balance, owner) and actions (deposit, withdraw).
  • A student has data (name, marks) and actions (submit assignment, view report).
A car, a bank vault, and a student standing side by side, each labeled with small icons for their data and actions.
chaicode.com
Notes
Look around you: a car, a bank account, a student — each bundles data with actions. OOP says: put the data and the actions together, in one unit. class Student { String name; int marks; void printReport() {...} } — aman.printReport();

Two Words For This Series

Class vs Object

Class

  • the blueprint.
  • Written once.

Object

  • a real thing built from the blueprint.
  • Created as many times as you need.
chaicode.com
Notes
Class: the blueprint. Written once. Object: a real thing built from the blueprint. Created as many times as you need.

Key Idea

A class is the blueprint of a house; objects are the houses built from it.
An architectural blueprint drawing morphing into several identical houses under construction.
chaicode.com
Notes
Key idea: a class is the blueprint of a house; objects are the houses built from it.

Why OOP Matters

Four practical problems, solved

ProblemHow OOP helps
Code becomes messy as it growsRelated data and logic live together in one class
Invalid data sneaks inObjects guard their own data and reject bad values
Same code copied everywhereReuse through inheritance and composition
Hard to change one part safelyChange a class's internals without breaking its users
chaicode.com
Notes
OOP is not about fancy syntax. It solves four very practical problems every real project faces.

Why Companies Care

OOP in the real world

  1. 01Teamsone developer owns Payment, another owns Order. Clear boundaries.
  2. 02Maintenancemost of a product's life is spent changing code, not writing it fresh.
  3. 03Testingsmall objects with clear jobs are easy to test.
  4. 04InterviewsOOP questions show up in almost every Java interview.
chaicode.com
Notes
Teams: one developer owns Payment, another owns Order. Clear boundaries. Maintenance: most of a product's life is spent changing code, not writing it fresh. Testing: small objects with clear jobs are easy to test. Interviews: OOP questions show up in almost every Java interview.

Key Idea

Changing Code Is Most Of The Job

OOP makes code easier to change, and changing code is most of the job.

A relaxed developer smiling while swapping one labeled puzzle piece into a large, neatly organized machine.
chaicode.com
Notes
Key idea: OOP makes code easier to change, and changing code is most of the job.