In Layman’s terms, Object Oriented Programming (OOP) is a way of modelling software in which everything is represented as objects. Object(s) can be any real-world or logical entity like a printing machine, coffee cup or financial firm. Each object has its own data and operations to perform on data. Each object can communicate with the other as and when required. This is similar to what we experience in the real world. Hence OOP got more popular than other types of programming paradigms in recent times.
The programmer needs to know everything about the real-world entity like the product, machine, service or any real-world entity before he starts writing the program for it. The first step of any programmer for developing software always would be modelling real-world entities with the help of OOP concepts. Anyone who understands OOP can model and develop any software in any programming language.
What is an Object?
An object is any real-time or logical entity created in the computer memory which consists of Data and Operations to perform on data. Following is an example of an automatic washing machine object of Front Load type, 8 ltr capacity etc.
What is Class?
Class is the blueprint or template of objects and with the help of the class, we can create the object(s) in the memory.
In the previous washing machine example, the electrical drawing will act as a Class/blueprint/template. So with the help of this electrical drawing(Class), anyone can create the number of washing machine(s).
Similarly, with the help of Class, we can create Objects that will perform the actual operations defined in Class.
Features of Object Oriented programming
Followings are features of object orient programming
What is Abstraction?
Abstraction defines high-level operations that an object should possess. Generally in abstraction, we focus only on what operations an object can perform rather than how to implement the intended operation. Abstraction helps at the design level or at the time of modelling software before actual implementation.
Let’s take the example of Lenovo PC company they want display parts from a vendor. So before the vendor delivers the actual Display parts, Lenovo signs a contract with the vendor which defines the Price of each part, delivery time, error rate etc. This contract is the actual abstraction and single source of truth during the period of the contract. This contract is signed before the actual delivery of the actual parts.
Similarly, abstraction in OOPs also acts as a single source of truth during the software development life cycle (SDLC). With the help of abstraction, we define object behaviour before the actual implementation.
For achieving Abstraction in any programming language we need to use Public, Private, Protected and Internal access specifiers.
What is Inheritance?
Inheritance means acquiring properties and behaviour from the Parent class.
In the above figure, the vehicle is a parent class which has some properties and operations which will be inherited by all Child classes. 4-wheeler, 3-wheeler & 2-wheeler can perform accelerate, brake and turn operations but also they have their own specific operations like “Turn On AC” in 4-wheeler.
What is Encapsulation?
In layman’s terms, Encapsulation is the process of putting things together with certain restrictions.
In the below example, Bank has gold, cash and some important paper stored (encapsulated) in a locker with restriction. Bank have provided access only to banker but not to any other person.
Similarly, In Object Oriented Programming, we encapsulate the object’s data and its operation in a single unit called Class with certain restrictions. Public, Private, Protected & Internal etc. are the types of restrictions and are called access specifiers. Access specifiers can be applied to data, operations and classes.
What is Polymorphism?
The ability to act differently in accordance with different input types is called Polymorphism. Polymorphism word is made up of two words i.e. Poly means “many” and morph means “change or form”.
Let’s take a real-time example, If you ask a driver to drive a car in the city he would drive at a max speed of 50km/h. But if you ask the same driver to drive the same car on the highway, he would drive at 100 km/h. It means depending upon the input you give to the driver he would drive the same car at a different speed. So in this example, the driver acted differently with different inputs.
Similarly in Object Oriented Programming, programmers can write pieces of code which will behave differently with different input types. There are two types of polymorphism
- Static or Compile Time Polymorphism
- Dynamic or Run Time Polymorphism
What are different Object Oriented Programming languages?
Here is the widely known list of Object Oriented Programming (OOP) languages.
If you know other OOP languages that are not present on the list, please feel free to comment.
What are other programming paradigms available?
There are several other programming paradigms available in addition to object-oriented programming (OOP). Some of the most popular include:
- Procedural programming
- Functional programming
- Logic programming
- Scripting programming
- Event-driven programming
- Aspect-oriented programming
- Imperative programming
- Declarative programming
- Concurrent programming
- Distributed programming
- Reactive programming
- Symbolic programming
- Component-based programming
- Generic programming
- Reflective programming
I hope this article may have helped you to understand something new in Programming if you have started exploring recently.
Please comment if you want specific articles on any other topic. Thanks for reading!
1 thought on “What is Object Oriented Programming (OOP) In Simple Words?”