|
In this article:
- What is Procedural Programming
- Procedural Programming as a Modular Programming Paradigm
- Comparision with Object-Oriented Programming
What is Procedural Programming?
Procedural programming is a programming paradigm which is works on a basic concept called the procedure call. Procedures are sometimes also called routines, subroutines, methods, or functions are units that contain a set of steps that are to be executed. A program is a collection of a number of procedures and of the procedures so defined maybe called at any time when the program is being executed. This calling is done by other procedures or the called procedure itself (called recursion). Some of the procedural programming languages are Visual Basic, Visual Foxpro, ALGOL, FORTRAN, Perl, PHP and PASCAL.
Advantages of Procedural Programming
Procedural programming presents us with certain key advantages that make it a better choice over many other paradigms. These are:
- It is apt for problems that are moderately complex and provides a certain degree of maintainability.
- Procedural programming makes it possible to use the same code again and again without having to copy it (called Polymorphism).
- It makes it easy to navigate in the program as instead of using statements such as ‘GOTO’ to control flow, it uses the name of the procedures themselves.
- The procedural programming paradigm is a strongly modular method making the program more readable and easy to handle and manipulate.
Procedural Programming as a Modular Programming Paradigm
When programs are large, they tend to get complicated. This calls for a method to separate each piece of code that can function by itself from each other. Modural programming is a way to achieve this where the whole program is divided into separate modules where each module is fully functional alone. Procedural programming is a modular programming paradigm as it divides the whole program into separate procedures that have a predefined input and output channels. Procedures in a procedural program are passed as an argument while ouputs maybe printed or act as input for some other procedure, which is, returned.
Procedural programming, through the process of scoping, that is, what part of the program is a variable active for, allows procedures to operate without getting confused between its own and the variables of other procedures which have the same name. A variable with a local scope (that is, a local variable) is active only within the procedure it is declared in and cannot be used by other procedures. On the other hand, global variables can be used by any of the procedures in the program.
Procedural programming implements modularity to a high degree. This is so because no matter how large a programming, it stays divided into procedures (separate entities). Another factor that contributes to this is that mostly, variables are not allowed to be modified by many procedures (by making them local in scope) which not only makes a program slow, but also makes it less modular.
As a modular programming paradigm, procedural programming presents some more advantages. These
are:
- It helps in making a simple interface
- It makes it easy to use the same code again and again
- It makes it easy to work on a particular portion of the program without affecting the other parts of the program.
- It makes it possible for people to use codes made by other people in a fast and easy manner (by simply making a procedure with them).
Comparison with object-oriented programming
While Object-oriented Programming (OOP) and Procedural Programming are both types of Modular programming itself, there are certain differences between the two. Firstly, object-oriented programming is a newer concept as compared to procedural programming. Secondly, object-oriented programming can achieve more sophisticated modularity. Since object-oriented programming deals with objects, instead of procedures, a single object can have more than one related procedure which means that the whole object can be seperated from the rest of the program with all the procedures related to it.
|