# #Flutter: A short intro to OOP

![Flutter](https://cdn.hashnode.com/res/hashnode/image/upload/v1621945142953/60E9VAR_Sn.jpeg)

For those of you, who haven't learned object-oriented programming language.

**I want to give you a short intro to this "Object-Oriented Programming"**


This would be highly beneficial to you, as Procedural programming is about writing procedures or functions that perform operations on the **data** while object-oriented programming is about creating objects that contain both **data** and **functions**.


didn't understand?


>Don't worry! You will understand soon :)

___

By the way, what are the advantages of ```Object-Oriented Programming``` and why it is important?

Because
> 
- OOP is faster and easier to execute
- OOP provides a clear structure for the programs
- OOP helps to keep the C++/Java/Dart code DRY "Don't Repeat Yourself", and makes the code easier to maintain, modify and debug
- OOP makes it possible to create full reusable applications with less code and shorter development time



#### Object-Oriented Programming is associated with concepts like Class, Object, Abstraction, Encapsulation, Polymorphism, and Inheritance.


First of all, what is a **class**?
>Class is what defines the properties and functions of any functional Entity. Like humans having body parts, clothes, etc.

>Collection of objects is known as a class.


>>For example, if you are a student studying in a college or school. 

>>Then all the students in your classroom are objects and the classroom itself is a class.
The `name`, `age` of a student can be assumed as **variable** and the `activities` he/she does in his/her whole day can be termed as **methods**

>>Like `sleeping()`, `eating()`, `crying`, `studying()`, etc


Now I think we are done with `class`, `objects`, `methods`. Now let's understand the important principles of OOP

The principles of object-oriented programming are **encapsulation**, **abstraction**, **inheritance**, and **polymorphism**.



>>I know all this is a bit hard to digest, but all these things will help you a lot in your programming journey.




>>I know these words sound scary, but don't worry they are not that scary as they look.

>I want to give you a short and simple explanation of these words!

>Are you ready?

>Now Let's Go........

 
**Encapsulation:**


Say we have a program. It has a few logically different objects which communicate with each other — according to the rules defined in the program.


Encapsulation is achieved when each object keeps its state private, inside a class. Other objects don’t have direct access to this state. Instead, they can only call a list of public functions — called methods.
 
>For example


>>1. When we buy a new Mobile phone, we don’t see how the circuit board works or how memory is managed. This irrelevant information is hidden. That hidden information is called “Encapsulation”

>>2. A capsule. Basically, the capsule encapsulates several combinations of medicine.

>>If combinations of medicine are variables and methods then the capsule will act as a class and the whole process is called Encapsulation.

>I hope you are done with Encapsulation. If not then please read these examples again. Or else join our [Telegram group](https://t.me/Bufferoverflowdotme) only made to help coders with the difficulties they were facing in their programming journey.


**Abstraction:**

Abstraction is a process of showing only the necessary data to the end-user.

>For example:

>In washing Machine
>>We just put dirty clothes and add the washing powder. The washing machine working internally brews the cloths and gives the clean cloths.


>>You don’t need to know what is happening inside the washing machine. Someone else worried about created a washing machine and that’s acts as “Abstraction” which shows you the only necessary things.


**Inheritance:**

The capability of a class to derive properties and characteristics from another class is called Inheritance.

> For example,
>>You are derived from your parents and they had been derived from their parents and ultimately you have some qualities and features of your both parents, and grandparents.




**Polymorphism:**


The word polymorphism means having many forms.

`Poly` means `many` and `morphḗ` mean `forms` in *greek*


In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. 

>A real-life example of polymorphism, a person at the same time can have different characteristics. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism. Polymorphism is considered one of the important features of Object-Oriented Programming.

___
So now we are done with some of the important concepts of OOP, but there's a lot to learn in OOP.

I condensed and summarized all the data available on the web for you.

I hope now you have, some brief idea about OOP.

If you want detailed information about OOP and also want to suggest something to me, please comment and join our [Telegram group](https://t.me/bufferoverflowdotme).

In the next article, we will be getting our hands dirty with some flutter code

Until then, stay home stay safe

Cya :-)

