What is OOP?
Object-Oriented Programming, more commonly known as OOP, was firstly introduced in the late 1950s and early 1960s in the Massachusetts Institute of Technology (MIT), United States.
OOP is a programming paradigm that simply divides the program into small parts called “Objects” which makes the task easier to handle.
OOP gives emphasis on data rather than the function which makes it more secure and robust.
In the early and mid-1990s, it became the most dominant programming methodology and was widely accepted due to the rising popularity of the Graphical User Interface, which depended on object-oriented programing techniques.
Nowadays a large number of object-oriented languages, like C++, Java, Python, Perl, Ruby are available.
In object-oriented programming, an Object is the most important element.
Now a question arises, what is an Object? Let’s find out.
What is an Object?
The object is an entity that has state, behavior, and unique identity.
State (Data) – Any characteristics or properties that tell us about any object.
Behavior (Functions) – All functions or capabilities of an object is its behavior.
For example – If we talk about a car, it’s color, size, brand name, engine, are it’s State whereas drifting, applying brakes, speed, are its Behavior.
Principles of OOP
- Encapsulation – Objects are basically made up of two things, State and Behavior. Encapsulation is a technique that binds State and Behaviour into one single entity (class) which makes the data more secure and prevents it from any kind of misuse and unauthorized access.
- Abstraction – Abstraction is a process that simply hides all the complexity of the program and only the necessary operations are shown up.
- Inheritance – Inheritance allows you to inherit/acquire the features of existing classes which enables you to reuse the code instead of writing it again.
- Polymorphism – Polymorphism divides into two root keyword Poly + Morphism. Where Poly means Many and Morphism means Form. Long story, short Polymorphism lets you use a single type of function in many ways.
What is POP?
Procedure-Oriented Programming also known as POP, was firstly introduced in 1960.
POP is a programming paradigm that divides the program into small parts called functions. POPgives emphasis on functions and the sequence of task completion.
How OOP differ from POP?
|Object-Oriented Programming||Procedure-Oriented Programming|
|OOP divides the program into small parts called objects.||POP divides the program into small parts called functions.|
|OOP gives emphasis on data rather than function.||POP gives importance to functions and the sequence of the task.|
|OOP provides access specifiers to control data access.||There is no access specifier in POP.|
|Some programming languages that follow OOP concepts are Java, Python, Ruby, C++, etc.||Programming languages that followed POP concepts are C, Fortran, Pascal, etc.|
Why programmers prefer OOP?
POP had some major disadvantages under OOP which made programmers switch to OOP based languages. Some of them were –
- Data implementation was a difficult task.
- No access specifiers made data insecure.
- Data hiding was improper.
- The importance given to functions made the program more lengthy and complex.
So these were the main reasons why almost all of us prefer OOP over POP. Any queries of yours could be resolved if you put it in the comment section.
Thanks for being here.