Object-Oriented Programming

In few words, I would say Oops mean “solving problems by creating objects”, but if we dig deeper then our lovable Oops states that:

Oops tries to map code instruction with real-world entities such as object, inheritance, abstraction, etc. And it makes the code short and easier to understand.

Classes and objects are the foundation of our Oops palace. Classes are logical components, they work as a blueprint for objects and don’t consume any space in memory.

In other words class is like a template where individuals(objects) fill in the information. An object is an instantiation of a class. Objects are physical entities, and every object has an address and occupies some space in memory.

Let’s take examples to understand more:

Consider the 5th standard of XYZ school, the whole class represents our Oops “class”. And each and every student will represent Oops “object”.

Photo by Austrian National Library on Unsplash

Now as according to human tendencies everyone must have their unique quality, so here that quality will represent the Oops attribute. And their works like doing homework, participating in activities, coming to school, etc will represent Oops methods.

  • Noun — Class — 5th standard
  • Adjective — Attributes — name, age
  • Verb — Methods — participatinginevents(), homework()

Now let's talk about another example that will justify more :

https://www.codewithharry.com/videos/java-tutorials-for-beginners-36

Here our form is working as a template (class) and we have defined all the required variables like name, class, grades, etc, now any student who fills that form will work as an object and all the info he/she will fill in are Oops attributes now the exam they will give is method here.

Noun — Class — Application form

Adjective — Attributes — name, age, grades

Verb — Methods — givingexam()

Now let’s look out at the 4 pillars of our Palace.

Data Abstraction

Data Abstraction is the way through which only essential info is shown to the user, by hiding all the internal details. Like our social media apps Instagram, Snapchat, we use them without bothering about their codings and their functioning

Polymorphism

the words mean “having many forms”, poly means many and morphs means form. it is the property that helps us to perform a single task in different ways. we can also define it as the ability of a message to be displayed in many other forms.

Encapsulation :

It is an act of putting various components together in a single unit named class. All the methods and variables of the class remain hidden from other classes.

Inheritance

It is an act of deriving new things from existing things. One class can acquire all the property and behavior of some other class. The class that inherits call subclass or child class. And the class that is inherited call parent class or superclass. inheritance helps us to write more efficient code because it increases the reusability of code. For example, Rickshaw → E-Rickshaw and Phone → Smart Phone and a child inherit the traits of his/her parents.

Now let's talk about our building advantages and disadvantages:

Advantages of Oops:

  1. Re-usability: write once and use multiple times.
  2. Redundancy: inheritance is the best way for data redundancy as if you want to use the same functionality for different classes then you can make the common class for the same functionality and later can inherit that class to sub-class.
  3. Easy maintenance: It makes our code easy to maintain and manage.
  4. Security: Data hiding and abstraction secure our data.

Disadvantages of Oops:

  1. size: Object-oriented programming codes are slightly bigger.
  2. speed: they are slightly slower because of their size.
  3. Efforts: Oops codes are harder to create mainly for beginners.

“No one is perfect” so rather than focusing on bad things we should appreciate what our oops have given to us.

Photo by Pongsawat Pasom on Unsplash

It was wonderful to talk with you, have a great day.

Have a quote to refresh your mind.

“If you ever start taking things too seriously, just remember that we are talking monkeys on an organic spaceship flying through the universe” — Joe Rogan

Computer Science Engineering student| AI enthusiast | Learner

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

OWASP Top 10 | TryHackMe|Broken Authentication| Task 6-7

How to abstract away implementation details and simplify your life: A Story

Don’t Buy Alexa Create Your Own Using Python -less than 50 Lines of Code

Alexa from Amazon

Documentation Revival Part 1: How to tame your documentation

MySQL Shell Python mode blog posts compilation

Internship journey at OASIS INFOBYTE

Learning go in 2022 — Boost your journey (part 1)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nikita pandey

Nikita pandey

Computer Science Engineering student| AI enthusiast | Learner

More from Medium

Stairway to Maven

A brief introduction to Competitive Programming

Recursion.

Basic Concepts of Object-Oriented Programming — Infovistar