Programmers have been tying various programming methodologies and techniques to control the process of software development in order to build a high-quality software. Since the invention of computers, many programming approaches have been tried. The main aim of the programmers was to handle increasing complexity of programmers and make the software more reliable and maintainable. Procedure oriented programming is a major technique evolved in this period. It was a very powerful tool that enabled programmers to write moderately complex programs fairly easy and was a successful tool over the last few decades. But it failed to show desired results in terms of bug-free easy to maintain, and reusable programs. Later Object oriented programming technique is introduced to eliminate some of the drawbacks.
Procedure Oriented Programming
In the Procedure Oriented Procedural approach, the problem is viewed as a sequence of things to be done such as reading, calculating and printing. Procedure Oriented Programming (POP) is a paradigm based upon the concept of the procedure call. The primary focus is given to function (procedure). Functions simply contain a series of computational steps to be carried out. Any given function might be called at any point during a program's execution, including by other procedures or itself. In other words POP basically consists of writing a list of instructions (or actions) for the computer to follow, and organizing these instructions into groups known as functions. And these actions are organized and the flow of control is assigned from one action to another.
Procedural programming is often a better choice than simple sequential or unstructured programming in many situations which involve moderate complexity or which require significant ease of maintainability. But it holds certain drawbacks also. 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. The global data are more vulnerable as it could be affected by any function. In a large program it is very difficult to identify what data is used by which function. This may increases the complexity of programming and reduce maintainability. It may also cause bugs to generate.
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 match and do not really correspond to the elements of the problem.
Some of the characteristics exhibited by procedure oriented programming are:
Emphasis on doing things (algorithms).
Large programs are divided into smaller programs known as functions.
The ability to re-use the same code at different places in the program without copying it.
Most of the function share global data.
Data move apparently around the system from function to function.
Functions transfer data from one place to another.
Employs top-down approach in program design.
Object Oriented Programming
The idea behind object-oriented programming is that a computer program may be seen as comprising a collection of individual units, or objects, that act on each other, as opposed to a traditional view in which a program may be seen as a collection of functions, or simply as a list of instructions to the computer. Each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent little machine or actor with a distinct role or responsibility.
OOP treat 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. OOP allows decomposition of a problem into a number of entities called objects and build data and functions around these objects. The data of an object can be accessed only by the functions of one object can access the functions of other objects.
Some of the important 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 tied together in the data structure.
Data is hidden and cannot be accessed by external functions.
Objects may communicate with each other through functions.
Follows bottom-up approach in program design.
Benefits of OOP
Object-oriented programming is claimed to promote greater flexibility and maintainability in programming, and is widely popular in large-scale software engineering. Furthermore this approach is often simpler to develop and to maintain, lending itself to more direct analysis, coding, and understanding of complex situations and procedures than other programming methods. OOP is widely accepted as good tool for Analyzing user requirements, Designing software, Constructing software, Reducing large problems to smaller, more manageable problems.
The major advantages of OOP are :
Simplicity: Software objects model real world objects, so the complexity is
reduced and the program structure is very clear;
Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system;
Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods;
Extensibility: Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones;
Maintainability: Objects can be maintained separately, making locating and fixing problems easier;
Re-usability: Objects can be reused in different programs.