OOP for Beginner

Prathamesh Satam
3 min readOct 1, 2021

Hello guys, I’m writing this article for beginners who want to learn basic oop’s concept. Here I’m going to talk about what is oops and what are the features available with the oops concept. I’m not mapping concepts with any language. We will see it in future articles. Let’s begin our journey.

What is OOP?

OOP stands for Object-Oriented Programming. OOP is a paradigm based on wrapping pieces of data (variables) and behaviour (methods) related to data, into a special bundle called objects. Objects are created using blueprint means Classes.

Dog Class Diagram

Variables mean name, gender referred to as State and Methods mean setName referred as behaviour in class. Simply we can say a class is a combination of state and behaviour. Where the state is hidden from the world and behaviour is exposed publicly. The dog is the name of the class or blueprint we have created. The sign plus represent public visibility and minus for private.

Pillars of OOP

OOP is based on 4 pillars, concepts that differentiate it from other programming paradigms. Which are as below:

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance

Abstraction:

Abstraction the word itself reveal what its stand for, Abstraction means the ability to show only essentials details. Eg. we have Car where we start the car by pressing a button but we don’t know what happens beneath the button press. Like which parts operate on simple press. We are just aware of a button and its behaviour we get after the operation.

Encapsulation:

In oop we have state and behaviour, wrapping these together into a single unit is called encapsulation. Where the state is private or hidden and behaviour is exposed to the world for functioning. We can say it data hiding capability of oop. In a technical context, we can say variables are hidden for other classes and only accessibly by methods of that class only.

It is possible to confuse between abstraction and encapsulation as both seems redundant. There are few basic difference

  • Encapsulation is data hiding whereas Abstraction is implementation hiding.
  • Encapsulation is combining both state and behaviour, while abstraction is exposing behaviour while hiding implementation under it.

Polymorphism:

Poly means many morphim means faces, simple terms many faces. Polymorphism means the ability to take more than one form. Means same name but different behaviour. Polymorphism can be performed by using method overloading, overriding and operator overloading.

In one line overloading is the same name but different parameters and behaviour. It is a compile-time polymorphism. Because behaviour linking is done at compile time.

Overriding is the same name, parameters but behave as per the provided context. It is run time polymorphism. Because behaviour linking is determined at run time by provided reference.

Inheritance:

It is a very important pillar in oop. It is a mechanism by which we can inherit the state and behaviour of the parent class. Depending on the visibility of state and behaviour. It provides reusability. Inheritance have multiple types like Single, Multilevel, Multiple, Hybrid. In the case of Inheritance, we have Parent class and child class, where child class can inherit state and behaviour of parent class also override or change the behaviour of parent class. This can be achieved by using the overriding principle.

These are some basic concepts related to OOP. Which every developer should know. In addition to this principle, we have types of relations between objects. We will see them in the next article. Thank you for reading hope it helped you.

--

--