Applying OOP in Real World Applications

As a programmer, or a computer science student, you might’ve heard or know something about the terms which are shown above. Actually you should have knowledge about these if you claim to be working in the software development or computer science field. Also, there is a chance that you might not have fully understood when and where all these features are applied in real life. This article focuses on the application of the most used programming paradigm —** Object Oriented Programming, **in real world problems.

So, Object Oriented Programming(OOP) is a programming paradigm(philosophy), which is based on the concept of “objects”, which can contain data, in the form of fields, and code, in the form of procedures.

There are four basic principles of OOPs: **Encapsulation, Abstraction, Inheritance, Polymorphism, **which will be discussed in the following sections.

Image for post

I took part in’s #iBelieveInDoing July challenge, in which we got to take part in some of their Micro-Experiences/Bytes focused on application of OOPs. I would recommend you all to go through that experience for some hands-on learning.

Here is a link to my previous article in the challenge on System Design:

Let’s Get Started with OOP principles!

We’ll be taking the example of a chat app like Whatsapp.


the action of enclosing something in or as if in a capsule.

Image for post


As the definition says, enclosing something in a capsule, the meaning of encapsulation in OOPs is quite intuitive, just like the other OOP principles.

Encapsulation is, containing all important information inside of an object, and only exposing selected information to the outside world. Attributes and behaviors are defined by code inside the class template. It helps in emulating real world objects/entities.

For Example, If we are writing code for a messaging app, we would have a message class, which would contain all the information about a particular message being sent, like — receiver, sender, message content, message id — and all it’s methods inside a single entity.

Image for post

Encapsulation in Python

As we can see, all the attributes of the message are “encapsulated” together inside a bundle(class).

Encapsulation helps by:

  • Providing Security: to access any information about a message object we would have to go through the public getter and setter methods (setSender, setReceiver, getSender, getReceiver).
  • **Protecting developers from common mistakes: **Only public fields & methods accessible, so developers don’t accidentally change something dangerous.
  • **Protects IP: **code is hidden in a class, only public methods are accessible by the outside developers

What is the drawback if we don’t use encapsulation? — Duplication of code. Low maintainability. Inconsistent behavior. Difficult to test. Possible inappropriate access/modification from external methods.

#abstraction #encapsulation #polymorphism #object-oriented #inheritance #oop

Applying OOP in Real World Applications