OOPS made easy
Tags: oop, programming, computerscience, codenewbie
Published: 2020-11-29 07:33:15

<h1>What is OOP ?</h1>
<p>Talking in technical terms, <b>Object-oriented programming System(OOPs)</b> 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.</p>

<b>Okay only 20 % of people can understand this term in this language so lets simplify this :</b>
<p>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.</p> 

<h3>1. Objects</h3>
<p>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.</p>

<h3>2. Classes</h3>
<p>Objects with similar properties and methods are grouped together to form a Class. Thus a Class represents a set of individual objects.</p>

<b>Example 1 :</b> A House
<p>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.</p>

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


<h3>3. Abstraction</h3>
<p>Abstraction means showing essential features and hiding non-essential features to the user.</p>

<b>Example 2 :</b> A T.V Remote
<p>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.</p>

<h3>4. Encapsulation</h3>
<p>It is done for security purposes.</p>

<h2>Encapsulation = Abstraction + Data Hiding.</h2>

<b>Example 3 :</b> A Car
<p>A car is having multiple parts..like 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.</p>

<h3>5. Inheritance</h3>
<p>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.</p>

![Inheritance](https://dev-to-uploads.s3.amazonaws.com/i/gyas48hlz3dp37fe6qb6.png)

<h3>6. Polymorphism</h3>
<p>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.</p>

<b>Example 4 :</b> A Woman
<p>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.</p>
<br>

<b>Summary :</b>
<p>We have talked about OOPs fundamentals Like Polymorphism, Encapsulation, Inheritance and classes with their respective examples.</p>

<b><i>Thanks For Reading !</i></b>
<br>

<i>Written by - GVP</i>