Search This Blog

Thursday, 26 May 2011

Procedure Oriented Programming(POP) vs Object Oriented Programming(OOP)

Procedure Oriented Programming (POP) :-

Conventional programming using high level languages such as COBOL,FORTRAN and C, is commonly known as procedure oriented programming(POP). In the procedure oriented approach, the problem is viewed as a sequence of things to be done such as reading, calculating and printing. A number of functions are written to accomplish these tasks. The primary focus is on functions.
Typical structure of procedure oriented programs
Procedure oriented programming basically consists of writing a list of instructions(or actions) for the computer to follow, and organizing these instructions into groups known as functions.While we concentrate on the development , very little attention is given to the data that are bing used by various functions.

In a multi-function program, many important data items are placed as global so that they may be accessed by all functions. Each function may have its own local data. Global data are more vulnerable to an inadvertent change by a function. In a large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure, we also need to revise all functions that access the data. This provides an opportunity for bugs to creep in.
Relationship of data and functions in procedural programming
Another serious drawback with the procedural approach is that it does not model real world problems very well. This is because functions are action-oriented and do not really correspond to the elements of the problem.

Some characteristics of Procedure Oriented Programming are :-

1) Emphasis is on doing things(algorithms).
2) Large programs are divided into smaller programs known as functions.
3) Most of the functions share global data.
4) Data more openly around the system from function to function.
5) Functions transform data from one form to another.
6) Employs top-down approach in program design.


Object Oriented Programming (OOP) :-

The major motivating factor in the invention of object oriented is to remove some of the flaws encountered in the procedural oriented approach. Object oriented programming treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it, and protects it from accidental modifications from outside functions.

Object oriented programming allows a decomposition of a problem into a number entities called objects and then builds data and functions around these objects. The data of an object can be accessed only by the functions associated with that object. However, functions of one object can access the functions of other objects.
Organization of data and functions in object oriented programming
The object oriented programming can be defined as an " approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand ". Thus, an object is considered to be a partitioned area of computer memory that stores data and set of operations that can access that data. Since the memory partitions are independent, the objects can be used in a variety of different programs without modifications.

Some characteristics of Object Oriented Programming are :-

1) Emphasis is on data rather than procedures or algorithms.
2) Programs are divided into what are known as objects.
3) Data structures are designed such that characterize the objects.
4) Functions that operate on the data are tied together in the data structure.
5) Data is hidden and cannot be accessed by external functions.
6) Objects may communicate with each other through functions.
7) New data and functions can be easily added whenever necessary.
8) Follows bottom-up approach in program design.


Benefits of Object Oriented Programming over Procedure Oriented Programming :-

1) Through inheritance, we can eliminate redundant code and extend the use of existing classes which is not possible in procedure oriented approach.

2) We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch which happens procedure oriented approach. This leads to saving of development time and higher productivity.

3) The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.

4) It is possible to have multiple instances of object to co-exist without any interference.

5) It is possible to map objects in the problem domain to those in the program.

6) It is easy to partition the work in a project based on objects .

6) The data-centered design approach enables us to capture more details of a model in implementable from.

7) Object oriented systems can be easily upgraded from small to large systems.

8) Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler.

9) Software complexity can be easily managed.

Related Posts Plugin for WordPress, Blogger...