DEV Community

Cover image for Object-Oriented Programming Concepts (OOPs) Simplified! ! !
Shravan Kumar B
Shravan Kumar B

Posted on • Edited on • Originally published at ohmyscript.com

Object-Oriented Programming Concepts (OOPs) Simplified! ! !

Alt Text

In this article, I would like to introduce a beautiful programming paradigm that solves a lot of real-life problems in terms of programming.

Let us look into what is OOPs, the ideology behind OOPs and also main concepts of OOPs. And the complete article would be described in Non Programming terms, i.e., in layman’s terms.

Note: Once you are done reading the article, and understand, learning the OOPs Languages would be easy. It would give better understandability to learn any OOPs languages.

What is OOPs?

Object-Oriented Programming is a programming paradigm/ way of writing a solution for a given problem statement.

In a simpler way, it is a way of writing computer programs that are using the idea of “Objects” as a reference to represent the data and methods.

Instance: Take a scenario, Building a car. Building a car has a lot of things that are to be taken care of.

  1. Drawing out a blueprint of how the car should look like.
  2. Things that are required to build a car.
  3. Things that should be accessible to the one who builds it.
  4. Things that are accessible to one who drives it.
  5. How things attached to it should function
  6. How different things help function the other things

Here things are the data and methods are functionality associated with that data. Object-Oriented Paradigm basically is an idea of binding both the data and functionality for the simplicity of finding real-world problems.

Basically, some real-world problems are efficiently solved when taken Object-Oriented Approach, say in the above instance, Building the car was the problem statement.

How we go about it, can be understood as we go ahead.

You might have read the term “Object” above. Wondering, what is an Object?

An Object is the basic fundamental unit of Object-Oriented Programming. It’s a unit formed by the data and the methods(things and how things function) which is built from a blueprint.

Taking the same instance as above, we can say, Car is an Object. It holds all the things and functions together to have the behavior of a vehicle.

Talking about Blueprint, reminds of another important term, “Class”, which basically is a blueprint for creating objects.

For instance, for a Car Blueprint, we take care of essential features like fuel, type of fuel, the engine to be used, design how it should look, on Ignition how the vehicle should function.. so on.

It’s possible to produce cars in series using the blueprint, without re-building the machine from scratch.

This basically gives a clear image of what OOPs is all
about.

Alt Text

Now, taking note of the major features of OOPs concepts:

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism

What do you mean by “Abstraction”?

It simply means showing the essential features of a module, hiding the details of internal functionality.

Example: A driver that uses the accelerator, doesn’t need to know how it precisely works at the Mechanic level. He only knows that if he presses the accelerator, the car accelerates.

Alt Text

Water is composed of Hydrogen and Oxygen, but we see is liquid water (Abstraction)

Now jumping into another term, “Encapsulation”,

It is a method of wrapping up the things (data) and in a way, it can function to do something productive(methods). Basically, putting together the data and methods together to classify them.In other words, we can also define it as, way of exposing a solution to a problem without requiring to fully understand the problem domain.

Alt Text

Class/Interface is one of the features that help implement Encapsulation at the programming level.

Example: In the Car designing/Integrating team, the members working on the Lighting system of the car don’t need to know how the Brake System in the car works, as simple as that.
Alt Text

Now, explaining the term “Inheritance

Inheritance”, as the word suggests is a way to inherit some features(methods) or things(data) from a parent to its child. This is an important feature in OOPs, which basically deals allows you re-define the model.

Alt Text

Another Example: There is a Car X and are planning to release a Model A and Model B for Car X.

Now Model A is already designed and implemented. Model B is almost the same except for the Tyre and Disc Brake System.

So, here what happens is, Model B can take the design of the Model A and alter as per their requirement for Tyre and Disc Brake System.

Made sense? They don't have to redesign it from scratch. Instead, they inherit the things and functionality from Model A.

Finally, talking of “Polymorphism

Polymorphism is a feature that defines the different implementation of the same objects.

To put in simple words, “Polymorphism is a feature that enables to define the same functionality in different forms.

Simple silly but effective example would be using 'Cut' as a polymorphic word;

  • Surgeon would begin to make an incision
  • Hair Stylist would begin to cut someone's hair
  • Actor would abruptly stop acting of the current scene

Alt Text

Another Example: Car X has Model A and Model B, where both need fuels to run the vehicle.

Say, Car A-Model A uses petrol and other uses diesel as its fuel. Hence, the design of Automotive Engine design varies though they perform the same functionality.

This is how simple OOPs concepts are. I hope you got at least little clarity on what OOPs is and what their features are.

This basically speaks OOPs in general terms.

If you really want me to write down the explanation of the OOPs in the programming point of view.

Drop comments.
This is a revised version of my Medium Post

Stay Tuned for more posts.
Connect me mrshravankumarb@gmail.com

Top comments (1)

Collapse
 
efpage profile image
Eckehard • Edited

OOP-concepts never had a chance in web programming, because HTML prevents the usage by design. In HTML, all identifiers are globally defined, so you have no chance to have a strict encapsulation.

Some time ago I made a project to overcome this issue and to make OO principles applicable for web projects. You can simply not use HTML at all in a browser, as all functions are accesible throuch the html-dom-api. So I created a convenient wrapper for this libray that was called DML, the Document Makeup Library (DML). The concept performs very well, so mybe you like to check out the result, which is released as Open Source. This really brings back the principles of OOP to the web.