OOP Overview

This article explains Object Oriented Programming (OOP).

What is an Object?

An object means what is real that is called an object. For example, a man having two legs, two hands and so on. That is called an object. Now what we said to this man?

It's called a class.

Class means it's a template or blueprint of an object.

For example you are a class and your legs and hands are called objects.

oops

Why to use OOP

Before OOP we used Functional Oriented Programming. In Functional Programming there are problems, like it is difficult to reuse. When a new programmer comes to development, it becomes difficult for some of them to understand. That's why OOP concept was introduced. Using Object and Class we are thinking the real world things easily and it's easy to understand for developers.

There are the following 4 properties of OOP:

  • Encapsulation
  • Abstraction
  • Inheritance
  • Polymorphism

Encapsulation

Encapsulation means hiding the complex.

Example

We know the laptop will work, but a laptop doesn't show you how to run inside that.

Abstraction

Abstraction means show what is necessary.

Example

We want my laptop key to work properly and take my input into my system, but we don't want a CD drive.

Abstraction Implement Encapsulation and vice versa.

Inheritance

Inheritance inherit something from others. It's basically used for a parent-child relationship.

Example

Let's assume one father has two children, both of the children inherit some property from the parents property.

Polymorphism

Polymorphism means one form have multiple behavior in different situation.

Example

A persons behavior is as a lecture when he was in school and the same person's behavior is as a parent when he is in the front of his children.

Some points to remember:

  • Polymorphism is used for decoupling.
  • Polymorphism doesn't work without inheritance.

Up Next
    Ebook Download
    View all

    OOP/OOD

    Read by 0 people
    Download Now!
    Learn
    View all