Sign in
Log inSign up

Oops Concepts Easily Explained...

Ankur Gupta's photo
Ankur Gupta
·Aug 16, 2021·

4 min read

Hii! Guys, So every computer science student must have got in this question at least once in his/her lifetime. And that question is What is oops?. So today i will try to explain the oops concepts to the best of my abilities😊😊.

So what is oops?

So the full form of oops is Object Oriented Programming System and it is the most common pattern of programming in today's software industry. Without using the concepts of oops it is very difficult to create a software, and even if we did create software without using oops concepts, managing the software would be very very difficult. So that is why oops is important.

Basic pillars of oops?

So there are mainly 4 pillars of oops...
1. Polymorphism
2. Inheritance
3. Data Encapsulation
4. Data Abstraction

1. Polymorphism

So First pillar is polymorphism, which is made up from 2 words poly means many and morph means forms, so polymorphism means many forms.

Now as the word suggests it means one name and many forms, using polymorphism we also implement DRY concept of developement which means Dont't Repeat Yourself.

Now let's understand it from a real world perspective. Consider Yourself a example, Suppose your name is Ankur.

Now Ankur is son of her mother, at the same time he is also brother of his sister, at the same time he is also a grandson of his grandfather.

As you can see here Ankur is one person but he has many forms, for someone he is brother, for someone he is son. In the same way polymorphism works.

We define a function and use it at different places. Polymorphism is of two types...
1. Compile Time Polymorphism
2. Run Time Polymorphism

2. Inheritance

As the words suggests, Inheritance means to inherit some features of parent into child. The Proper defination of inheritance is The capability of a class to derive properties and characteristics from another class is called Inheritance.

Now, we wont take the defination seriously and let's understand this as a example.

Again consider yourself as a example, so you are child of your mother and father. So must have inherited many features from them only. Someone might have similar face as his/her mother, or someone might have eyes like his/her father.

So the point is you have inherited features of your mother and father in yourself. The types of inheritance are as follows...
1. Single Inheritance
2. Multi Level Inheritance
3. Multiple Inheritance
4. Hierarical Inheritance
5. Hybrid Inheritance

3. Data Encapsulation

So the third pillar is data encapsulation, so you might have eaten capsule, yes that capsule which doctor gives us 😂, inside that capsule contains a powder like substance which is actual medicine, and capsule is just the covering to protect that.

In the same way data encapsulation is a technique to put our data into a capsule, so it could be protected. Because data is most important thing in software developement, so we have to protect it.

So data Encapsulation is binding data members and member functions into a single unit.

So i think u must have understood the concept of data encapsulation.

4. Data Abstraction

So the Fouth pillar is data abstraction, so there is a lot of confusion in data abstraction and encapsulation as they both look same.

So data abstraction is showing only the nessacery details and hiding the complexity below the hood.

Let's understand this from example, consider yourself driving a car, so while driving the car you know that if you press accelarator car would move forward. Do you know when you press accelarator what happens behind the hood ?? Probably not.

In the same way when you print something in c. You write printf("Ankur") and it prints on the screen. Do you know that what happens inside how it converts it into bits or assembly language. No

So data abstraction just removes unnessacery details and focuses on the important part only.

Hope you would have liked my blog, I tried my best to explain the concepts as close to the real world. So until next time till then Happy Coding😊😊

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct