(OOPs) Object Oriented Programming Concept | Inheritance Polymorphism Abstraction Encapsulation

OOPs (Object-Oriented Programming System) | Inheritance Polymorphism Abstraction Encapsulation

Object Oriented Programming is a methodology to design a program using classes and objects that works on the principles of abstraction, encapsulation, inheritance, and polymorphism. 
It simplifies software development and maintenance by providing some concepts:
  • Object
  • Class
  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation
Object Oriented Programming Concept


Why OOPs concept is used?
Object-oriented programming aims to implement real-world entities like inheritance, Encapsulation, polymorphism etc. in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.

Object: It is a basic unit of Object Oriented Programming and represents the real life entities. It is an instance of a Class. It contains properties and functions. An object consists of State, Behavior and Identity.
Example: A House is an object because it has states like Address, Color, Area, etc. as well as behaviors like Open door, close door, etc.

Class: A class is a user defined blueprint or prototype from which objects are created. It is also called collection of objects.
Example: Vehicle is a class, because we have different kinds of Vehicle in the world and all of these belong to a class called Vehicle.

Inheritance: Inheritance is one of the most powerful concepts of OOPs. When one object acquires all the properties and behaviors of a parent object, it is known as inheritance.
The class which inherits the properties is called child class/subclass and the class from which properties are inherited is called parent class/base class.
Inheritance supports the concept of reusability, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class.

Polymorphism: Polymorphism is a feature that allows us to perform a single action in different ways. We can also say that If one task is performed in different ways, it is known as polymorphism.
For example: We can draw a shape in different ways i.e. Circle, triangle, rectangle, etc.

Abstraction: Data Abstraction is the property by which only the essential details are displayed to the user. The the non-essentials units are not displayed to the user.
In simple words Abstraction is a process where you show only “relevant” data and “hide” unnecessary details of an object from the user. 
For example, when you login to your bank account online, you enter your user id and password and press login, what happens when you press login, how the input data sent to the server, how it gets verified is all abstracted away from you.

Encapsulation: Binding code and data together into a single unit are known as encapsulation. It is the mechanism that binds together code and the data it manipulates. Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield. For example, a capsule, it is wrapped with different medicines.

Some of the advantages of object-oriented programming include:
  • Improved software-development productivity
  • Improved software maintainability
  • Faster development
  • Lower cost of development
  • Higher-quality software
  • It is easy to maintain and modify existing code.

No comments: