Welcome to Our Oops Palace.
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”.
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 :
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 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
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.
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.
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:
- Re-usability: write once and use multiple times.
- 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.
- Easy maintenance: It makes our code easy to maintain and manage.
- Security: Data hiding and abstraction secure our data.
Disadvantages of Oops:
- size: Object-oriented programming codes are slightly bigger.
- speed: they are slightly slower because of their size.
- 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.
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