Object Oriented Programming? Explanation of OOPS

What is Object Oriented Programming (OOP)?

Object oriented programming or OOP is basically a programming style followed by the programmers, in order to create an extensive set of software and applications.

This concept is purely based on the collection of classes and objects.

Now you might be thinking about what we mean by that ?. Well, to understand more about them we first need to identify the former way of doing programming.

Also Read – What is Programming | Introduction | How to begin?

What was the Former way?

Object Oriented Programming oop

Earlier programming was done using procedural languages such as “C” and “COBOL“.

By the word procedural we mean structural programming. Structural programming refers to that type of programming in which series of steps ( instructions ) are followed by the compiler in order to get the task done.

Also Read – C Programming | Introduction | features – For beginners 

Object Oriented Programming oop

This type of paradigm or model was not efficient for the today’s world. Why? Because it has some major flaws in it. For example, if a programmer wants to use some code which is already written in a program, then he/she had to re-write it. As there is no such functionality available for it.

This was very time consuming and needs a hell lot of effort.

Whereas with the introduction of object oriented programming (OOP) a programmer can reuse the code in numerous ways.

For instance, With the use of classes and objects, we can create a parent class to inherit all its features into the derived class.

Now, what are the classes and Objects?

Classes refer to the collection of objects. Objects can be the real world entities such as a car, bike, truck etc. All these entities have something common in between and that is they all are vehicles.

So we can merge them by a one-word category called as vehicles.

In programming, we can use vehicles as a class and car as its object. For better understanding follow the image below.

Object Oriented Programming oop

This image clearly depicts the understanding of classes and objects.

Here the car is a class which has three different branded vehicles ( Objects )

  • Mercedes
  • BMW
  • Audi

Below is the syntax of a class in a program.

Object Oriented Programming oop

Classes also tell us what kind of objects it has and what further data those objects has.

Benefits of OOP or Object Oriented Programming

OOP or Object Oriented Programming is also used for other purposes such as inheritance, polymorphism, data abstraction and much more.

Following are the benefits provided by OOP or Object Oriented Programming.

  • Inheritance- Inheritance simply refers to cloning with additional features. In programming, we can create as many classes as we want. But those classes must have at least one parent class. We can also inherit the features of that parent class into any other derived class. This allows programmers to reuse the already written code without worrying about writing it again.
  • Data Abstraction- Class has unique names and this feature comes in handy in many ways. Through the use of access specifiers, we can control the classes as they contain data. Access specifiers such as public, private and protected allow what type of access a user can have. When the object of the class is run then the code won’t be able to accidentally access other program data.
  • Encapsulation –  Wrapping up of data into a single unit is known as Encapsulation. It’s a classy feature as it allows the programmer to keep the access of data only limited to that module in which it is defined or declared. In simple words, it is not accessible to the outside world, only those functions which are wrapped in that module or class can access it.
  • Polymorphism – Poly means many and morphism means forms. So the word polymorphism simply means the ability to take many forms.
  • New Data Types – Classes allow programmers to create their own data types. Its a great feature as a programmer can make use of it any number of times at any number of places in a program or code.

Disadvantages of OOP or Object Oriented Programming

Like any other entity in the world OOP or Object Oriented Programming also has some flaws in it. Below is the list of disadvantages of having OOP or Object oriented programming paradigm in the programs.

  • Steep Learning Curve – The thought process behind writing the OOP or Object Oriented programming based programs can be a bit tricky to some people. It can also take time to get used to. Some people may find it complex to create object based programs as well.
  • Slow Speed – Object oriented programs tend to be slower than procedure based programs. The main reason behind this is object oriented programs require more instructions to be executed.
  • Unsuitable – There are some problems which can’t be solved by applying object oriented approach. That requires a procedural programming paradigm only. So you must have to keep this in mind.

Conclusion –

Object-oriented programming or oop is not only the one paradigm to be followed there are some others as well. You only need to identify which suits you best for your requirement.

Also Read – 

So this was all regarding object oriented programming or OOP.

Stay tuned for more.

1 thought on “Object Oriented Programming? Explanation of OOPS”

Leave a Comment