DEV Community

Anushka Shinde
Anushka Shinde

Posted on

I Learned OOP in College - But Nobody Showed Me Where It Actually Lives

You order food on Swiggy.Behind that screen there's a User object, an Order object, a Restaurant object.All talking to each other. All built using OOP.

College taught me classes, objects, inheritance, polymorphism, encapsulation, abstraction.I memorized definitions. Drew diagrams. Passed the exam.

Then I sat down to build a real project and stared at a blank file not knowing where to start.

Here's where every OOP concept actually lives in the real world.
Real example first, then the concept, then where to use it.


🧑‍💻 Swiggy has Users, Restaurants, and Delivery Partners. All different. All stored separately.

Concept: Class and Object

A class is a blueprint. An object is the real thing built from that blueprint.

On Swiggy User is a blueprint.
Every person who signs up becomes a new User object with their own name, address, and order history.

Restaurant is another blueprint.
Every restaurant on the platform is a Restaurant object with its own menu, ratings, and location.

Same blueprint. Thousands of different objects.

Use it when: Every entity in your project User, Product, Order, Doctor, Donor becomes a class.


🏥 A hospital system has Doctors, Nurses, and Receptionists. All are Staff. But all do different things.

Concept: Inheritance

When one class inherits properties and behavior from another.

Doctor, Nurse, and Receptionist are all Staff.All have a name, staff ID, and can clock in and out.

Instead of writing those details three times Doctor, Nurse, and Receptionist all inherit from Staff.Each one only adds what makes them unique.

Doctor adds diagnose().
Nurse adds assistSurgery().
Receptionist adds scheduleAppointment().

Use it when: Multiple entities share common properties. Don't repeat yourself inherit instead.


💳 You pay on Swiggy. Sometimes UPI. Sometimes card. Sometimes cash. Same button. Different behavior.

Concept: Polymorphism

Same method name. Different behavior depending on the object.

processPayment() works for UPI, Card, and Cash.You press the same Pay Now button every time. But what happens inside is completely different for each payment type.

That's polymorphism one interface, many forms.

Use it when: Multiple classes do the same thing differently payment methods, notification types, login types, shipping methods.


🔒 You use a banking app. You see your balance. You cannot directly change it from outside.

Concept: Encapsulation

Hide the internal data. Expose only what's needed through controlled methods.

Your bank balance is private.
You cannot just type a number and change it directly.
You have to go through deposit() or withdraw() where rules and validations are enforced.

That protection is encapsulation.

If balance were public anyone could set it to any number.
Making it private and controlled keeps the system honest and secure.

Use it when: Any sensitive data passwords, balances, medical records should be hidden and only accessible through controlled methods.


🚗 You use Uber. You press "Book Ride." You have no idea how the algorithm finds your driver.

Concept: Abstraction

Show only what the user needs. Hide the complex implementation.

You just press Book Ride.You don't see the driver matching algorithm.You don't see the surge pricing calculation.You don't see the route optimization logic.

That's abstraction defining WHAT something does without exposing HOW it does it.

Use it when: You want a clean simple interface hiding complex logic underneath. The user interacts with the surface. The complexity lives inside.


📱 Every Netflix account has a profile. Every profile remembers your watch history separately.

Concept: Constructor

A constructor initializes an object the moment it is created.

When you create a Netflix profile a Profile object is instantly created with your name, preferences, and an empty watch history.

The constructor makes sure no Profile object can exist without the essential information already set.

Use it when: Every entity needs to be created with initial values already set users, profiles, orders, accounts.


📧 Gmail sends millions of emails. It doesn't create a new mail server for each one.

Concept: Static Methods

Static belongs to the class itself not to any individual object.
One copy. Shared by everything.

Utility operations like sending emails, generating unique IDs, formatting dates these don't need a new object created every time.
They live as static methods and are called directly.

Use it when: Helper functions, utility operations, and shared counters that don't depend on individual object state.


📊 The Honest Summary

Real World Scenario OOP Concept
User, Restaurant, Order on Swiggy Class and Object
Doctor and Nurse are both Staff Inheritance
UPI, Card, Cash all process payment Polymorphism
Bank balance hidden from direct access Encapsulation
Book Uber without seeing the algorithm Abstraction
Netflix profile created with instant details Constructor
Gmail sends emails without new server each time Static

Final Thought

OOP is not about memorizing definitions.

It's about looking at the real world and asking what are the entities here?what do they share?what makes each one unique?what should be hidden?what should be exposed?

Every app you use daily is already answering those questions.
Swiggy. Uber. Netflix. Gmail. Instagram.

Once you see OOP in the apps around you it stops being exam theory
and starts being how you think. 😊


Which OOP concept finally clicked for you
when you saw it in a real app?

Drop it below 👇

Top comments (0)