Wednesday, 3 February 2016

Object Oriented Paradigm

1.4 Object Oriented 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 system. It ties data more closely to the function that operate on it, and protects it from accidental modification from outside function. OOP allows decomposition of a problem into a number of entities called objects and then builds data and function around these objects. The organization of data and function in object-oriented programs is shown in fig.1.3. The data of an object can be accessed only by the function associated with that object. However, function of one object can access the function of other objects.


Some of the features of object oriented programming are:
  • 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.
  • Functions that operate on the data of an object are ties together in the data structure.
  • Data is hidden and cannot be accessed by external function.
  • Objects may communicate with each other through function.
  • New data and functions can be easily added whenever necessary.
  • Follows bottom up approach in program design.
Object-oriented programming is the most recent concept among programming paradigms and still means different things to different people.
Read More »

Procedure-Oriented Programming


1.3 Procedure-Oriented Programming

In this approach, the problem is viewed as the sequence of things to be done such as reading, calculating and printing such as cobol, fortran and c. The primary focus is on functions. A typical structure for procedural programming is shown in fig.1.2. The technique of hierarchical decomposition has been used to specify the tasks to be completed for solving a problem.


Procedure oriented programming(POP) basically consists of writing a list of instructions for the computer to follow, and organizing these instructions into groups known as functions. We normally use flowcharts to organize these actions and represent the flow of control from one action to another.

In a multi-function program, many important data items are placed as global so that they may be accessed by all the 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.

Another serious drawback with the procedural approach is that we do not model real world problems very well. This is because functions are action-oriented and do not really corresponding to the element of the problem.

Some Characteristics exhibited by procedure-oriented programming are:

  • Emphasis is on doing things (algorithms).
  • Large programs are divided into smaller programs known as functions.
  • Most of the functions share global data.
  • Data move openly around the system from function to function.
  • Functions transform data from one form to another.
  • Employs top-down approach in program design.
Read More »