Posted in Information Technology & Systems, Total Reads: 773
Definition: Object Oriented Programming (OOP)
OOP is a programming paradigm, a method to build and write computer programs that use objects and the interactions between different objects to structure programs and write software applications. The focus of OOP is data rather procedures and thus does not allow it to flow freely in the system. Hence, the concept of “Object” in OOP evolved which refers to an instance of a class; a collection of variables of data types and the functions that operate on the variables which are called methods. These objects can store, send and receive data pertaining to the different classes.
For example, “Cars” can be a class consisting of variables such as “brand”, “price”, and “mileage” and methods that use these variables. “Alto”, “Santro” are instances of the class “Cars”.
The Object Oriented Paradigm implements the following concepts by means of classes and objects to enable programmers to represent, modify and reuse large real life data and applications easily:
Modularity: It is a process by which, the entire code of the program is decomposed into a set of loosely coupled, cohesive and logical modules. This enables design, development, test and maintenance of each module independently thereby making the addition of new data or code easier, as the program is now more structured.
Encapsulation: The data in the form of variables and the functions operating on the data are all combined into a single unit known as a class. This concept is called encapsulation.
Data Abstraction: The process of data abstraction in OOPs refers to presenting only the essential information to the user while hiding the background details. For example, the class “car” may contain various variables such as “engine power”, “suspension system”, “brake system” etc. The user need not know how each works, all he requires is an interface to assemble them into a fully functional “car”. This concept can be extended to OOP.
Inheritance: It is a concept by which one class (derived class) can inherit the properties of another class (base class). The concept of reusability and extensibility is achieved through inheritance. For example, the class “Cars” can acquire all the properties of the parent class “Vehicles”. Similarly, if a new class “Bikes” needs to be created, it can be added easily through inheritance from the class “Vehicles”.
Data Hiding: The data is protected within the class as variables that can be accessed only by the methods and functions in the class. Through the object, only the methods that use the data can be invoked and not the data itself. This prevents any accidental modification of data values.
Polymorphism: Polymorphism refers to a programming language's ability to process objects differently depending on their data type or class.
Examples of object oriented programming languages are C++, JAVA and Smalltalk.