DEV Community

Cover image for Object Oriented Programming with a Real-World Scenario - Part 1
Hashim Lokasher
Hashim Lokasher

Posted on • Edited on

Object Oriented Programming with a Real-World Scenario - Part 1

In interviews, young programmer are asked for a real world scenario explaining OOP and many fail to answer. This is the reason I am writing this article. This article is mainly intended for the audience who knows the Object Oriented Programming (OOP) concept theoretically but are unable to link it with real world & programming world.

We write programs to solve our problems and get our work done.

Object Oriented Programming is considered as a design methodology for building non-rigid software. In OOPS, every logic is written to get our work done, but represented in form of Objects. OOP allows us to break our problems into small unit of work that is represented via objects and their functions. We build functions around objects.

There are mainly four pillars (features) of OOP. If all of these four features are presented in programming, the programming is called perfect Object Oriented Programming.

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism

Let's consider an example explaining each of these pillars so you can better understand Object Oriented Programming.

Before that, we need to know something.

When we think of a mobile phone as an object, its basic functionality for which it was invented were Calling & Receiving a call & Messaging. But now a days thousands of new features and models were added and the features and number of models are still growing.

Mobiles Image

In above diagram, each brand (Samsung, Nokia, IPhone) have their own list of features along with basic functionality of dialing, receiving a call and messaging.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️