Before starting with OOPS programming paradigm, first let us discuss about Procedural programming.
Procedural programming is the subset of Structured programming. From name it is clear that it uses list of instructions to tell system/computer what to do step-by-step. Example of some of the procedural languages are C, Fortran, Cobol.
The pictorial representation of how any procedural language works is described below-
From the above diagram it is clear that procedural language segregates a program as
functions. Using functions the data and variables are manupulated to perform a task. These procedures can be invoked anywhere between the program hierarchy, and by other procedures as well.
OOPS is another way to perform any task in which computation is carried using objects. For a computer object represents real world entity which contains variable and methods. Interaction with other elements in programme is carried using object.
Let us examine below representation-
Let us consider any real world entity person which contains attributes like height, weight, qualification and behaviour which can manipulate the attributes of person. In OOPS, person object is used to interact with other objects like employee object or vice versa. Lets say that a person is eligible to be an employee of an organization if he has certain qualification. Such manipulation/processing can be done using employee object and person object. To represent object i.e. person we need template. This template in
OOPS is known as
class which represents the blue print of any object which actually contains the blueprint what actually person looks like and what a person can do.
Some of the key features that OOPs provides are described below-
Encapsulation : Encapsulation means data hiding which is actually wraps the data and behaviour together.
Inheritance : Inheritance is the mechansim by which one objecct can acquire the properties and behaviour of another object(parent object).
Polymorphism : Polymorphism is the mechanism by which one object can behave differently based on data set.
Some of the key benefits of OOPs are described below-
Re-usability : You can write a program using a previous developed code.
Scalability : OOPS provide high level of scalability. For example any class can be extended to add additional features or specialize based on future needs.
Modular Approach : It beccomes each to modularize any task and partition based on object. The individual modules can work standalone and can be integrated easily.
Data-Hiding : Using encapsulation, one can expose the attributes to be manipulated but the manipulation/behaviour is wrapped in individual class and other program cannot break the implementation.
Class : Class is the blueprint/template for any object which defines set of variables and behaviour any object can possess.
Object : Object is the actual representation of any class which posses the actual data and behaviour.
Attribute : Attributes can be defined as the representational set of values for any object.
Method : Methods represents the behaviour any object possess.
In this chapter, we learnt about OOPS programming language and its advantage over Procedural language.