Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Object-Oriented Programming Paradigm

 The major motivating factor in the invention of object-oriented approach is to remove


some of the flaws encountered in the procedural approach.
 OOP treats data as a critical element in the program development and does not allow
it to flow freely around the systems.
 It ties data more closely to the functions that operate on it, and protects it from
accidental modification from outside functions.
 OOP allows decomposition of a problem into a number of entities called objects and
then builds data and functions around these objects.
 The data of an object can be accessed only by the function associated with that object.
 However, functions of one object can access the functions of other objects.

Features of object-oriented programming

 Emphasis is on data rather than procedure.


 Programs are divided into what are known as objects.
 Data structures are designed such that they characterize the objects.
 Data is hidden and cannot be accessed by external functions.
 Objects may communicate with each other through functions.
 New data and functions can be easily added whenever necessary.
 Follows bottom-up approach in program design.

Difference Between POP & OOP

Difference Between Procedure Oriented Programming (POP) & Object Oriented


Programming (OOP) is given below.

Type Procedure Oriented Programming Object Oriented Programming

Divided Into In POP, program is divided into small parts In OOP, program is divided into parts called
called functions. objects.

Importance In POP,Importance is not given to data but In OOP, Importance is given to the data
to functions as well as sequence of actions rather than procedures or functions because
to be done. it works as a real world.

Approach POP follows Top Down approach. OOP follows Bottom Up approach.

Access POP does not have any access specifier. OOP has access specifiers named Public,
Specifiers Private, Protected, etc.

Data Moving In POP, Data can move freely from In OOP, objects can move and communicate
function to function in the system. with each other through member functions.

Expansion To add new data and function in POP is OOP provides an easy way to add new data
not so easy. and function.

Data Access In POP, Most function uses Global data for In OOP, data can not move easily from
sharing that can be accessed freely from function to function,it can be kept public or
function to function in the system. private so we can control the access of data.

Data Hiding POP does not have any proper way for OOP provides Data Hiding so provides
hiding data so it is less secure. more security.

Overloading In POP, Overloading is not possible. In OOP, overloading is possible in the form
of Function Overloading and Operator
Overloading.

Examples Example of POP are : C, VB, FORTRAN, Example of OOP are : C++, JAVA,
Pascal. VB.NET, C#.NET.

Basic Concepts of OOP

1. Class
2. Objects
3. Encapsulation
4. Abstraction
5. Polymorphism
6. Inheritance
7. Dynamic Binding
8. Message Passing

1. Object

Any entity that has state and behavior is known as an object. For example, a chair, pen, table,
keyboard, bike, etc. It can be physical or logical.

An Object can be defined as an instance of a class. An object contains an address and takes
up some space in memory. Objects can communicate without knowing the details of each
other's data or code. The only necessary thing is the type of message accepted and the type of
response returned by the objects.

Example: A dog is an object because it has states like color, name, breed, etc. as well as
behaviors like wagging the tail, barking, eating, etc.

2. Class

Collection of objects is called class. It is a logical entity.

A class can also be defined as a blueprint from which you can create an individual object.
Class doesn't consume any space.

Class Object
Apple

Fruit Banana

Mango

3. Inheritance

When one object acquires all the properties and behaviors of a parent object, it is known as
inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
4. Polymorphism

If one task is performed in different ways, it is known as polymorphism. For example: to


convince the customer differently, to draw something, for example, shape, triangle, rectangle,
etc.

In Java, we use method overloading and method overriding to achieve polymorphism.

5. Abstraction

Hiding internal details and showing functionality is known as abstraction. For example phone
call, we don't know the internal processing.

In Java, we use abstract class and interface to achieve abstraction.

6. Encapsulation

Binding (or wrapping) code and data together into a single unit are known as encapsulation.
For example, a capsule, it is wrapped with different medicines.

 Technically in encapsulation, the variables or data of a class is hidden from any other
class and can be accessed only through any member function of own class in which they
are declared.
 As in encapsulation, the data in a class is hidden from other classes, so it is also
known as data-hiding.
 Encapsulation can be achieved by Declaring all the variables in the class as private
and writing public methods in the class to set and get the values of variables.

7. Dynamic Binding

In Dynamic binding compiler doesn’t decide the method to be called. Overriding is a perfect
example of dynamic binding. In overriding both parent and child classes have same method .
Dynamic binding (late binding) means that the code associated with a give procedure call is
not known until the time of the call at run-time.

8. Message Passing

Objects communicate with one another by sending and receiving information to each other. A
message for an object is a request for execution of a procedure and therefore will invoke a
function in the receiving object that generates the desired results. Message passing involves
specifying the name of the object, the name of the function and the information to be sent.

Benefits of OOP:

1. Through inheritance we can save code and use existing class. And by this way we can
save time.
2. Data hiding provides the security of our data and data can’t be accessed accidentally
or avoid misuse of it.
3. We can create multiple objects from one class.
4. We can match the problem in real world with the program.
5. We can divide the work into multiple modules based on object.
6. We can easily upgrade our system from small to large one.
7. Software complexity is reduced.
8. It is easy to develop the system for the programmer.

You might also like