DEV Community

Cover image for OOPS made easy

OOPS made easy

Gudi Varaprasad
Cyber Security | Cryptography | Blockchain | Front-end | Mathematics | Computer Science | VIT
・3 min read

What is OOP ?

Talking in technical terms, Object-oriented programming System(OOPs) is a programming paradigm based on the concept of “objects” that contain data and methods. … Object-oriented programming brings together data and its behavior(methods) in a single location(object) makes it easier to understand how a program works.

Okay only 20 % of people can understand this term in this language so lets simplify this :

This was hard for me in the beginning but when I started implementing the concepts I learned, reading blogs, exploring real-life scenarios, it became easy for me. In this blog, I will make the concepts clear for everyone by giving real-life examples.

1. Objects

Objects are identified by their unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data. An Object is a collection of data members and associated member functions also known as methods.

2. Classes

Objects with similar properties and methods are grouped together to form a Class. Thus a Class represents a set of individual objects.

Example 1 : A House

An architect will have the blueprints for a house….those blueprints will be plans that explain exactly what properties the house will have and how they are all laid out. However it is just the blueprint, you can’t live in it. Builders will look at the blueprints and use those blueprints to make a physical house. They can use the same blueprint to make as many houses as they want….each house will have the same layout and properties. Each house can accommodate its own families…so one house might have the Prasad live in it, one house might have the Jack live in it.

1. Class = The blueprint of house
2. Object = The house
3. Data stored = Jack, Prasad, people living in house

3. Abstraction

Abstraction means showing essential features and hiding non-essential features to the user.

Example 2 : A T.V Remote

Remote is a interface between user and TV.. which has buttons like 0 to 9 ,on/off etc. but we don’t know circuits inside remote. User does not need to know. Just he is using essential thing that is remote.

4. Encapsulation

It is done for security purposes.

Encapsulation = Abstraction + Data Hiding.

Example 3 : A Car

A car is having multiple steering, wheels, engine…etc.. which binds together to form a single object that is a car. So, Here multiple parts of cars encapsulate themselves together to form a single object that is Car.

5. Inheritance

Deriving a new class from the existing class is called Inheritance. Derived(sub class) class is getting all the features from Existing (super class\base class) class and also incorporating some new features to the sub class.


6. Polymorphism

Ability to take more than one form that an operation can exhibit different behavior at different instance depend upon the data passed in the operation.

Example 4 : A Woman

If a girl is married and mother of 2 children doing a teaching job then she is a woman first, a teacher in a school when she is in school, wife of someone at home, mother of her children, and obviously daughter of someone.

Summary :

We have talked about OOPs fundamentals Like Polymorphism, Encapsulation, Inheritance and classes with their respective examples.

Thanks For Reading !

Written by - GVP

Discussion (2)

bias profile image
Tobias Nickel

Can't resist to share this post from the stackoverflow blog here:

If everyone hates it, why is OOP still so widely spread?

bias profile image
Tobias Nickel

wow, just today, someone also shared the 4 pillars of OOP, you got 6,... what is better?😏

Forem Open with the Forem app