Procedural programming is a programming paradigm based upon the idea of a procedure call. Procedure calls are modular and are bound by scope. A procedural program is composed of one or more modules.
Each module is composed of one or more subprograms. Modules may consist of procedures, functions, subroutines or methods, depending on the programming language. Procedural programs may possibly have multiple levels or scopes, with subprograms defined inside other subprograms. Each scope can contain names which cannot be seen in outer scopes.
Procedural programming offers many benefits over simple sequential programming since procedural code:
- It is easier to read and more maintainable
- It is more flexible
- It facilitates the practice of good program design
- It allows modules to be reused in the form of code libraries
In the procedure oriented approach, the problem is viewed as sequence of things to be done such as reading , calculation and printing. Procedure oriented programming basically consist of writing a list of instruction or actions for the computer to follow and organizing these instruction into groups known as functions.
In Procedural programming, data and functions (subroutines, procedures) are
kept separate from the data they process. This has a significant effect on the way a program handles data:
- The programmer must ensure that data are initialized with suitable values before use and that suitable data are passed to a function when it is called.
- If the data representation is changed, e.g. if a record is extended, the corresponding functions must also be modified.
The disadvantage of the procedure oriented programming languages is:
- Global data access
- It does not model real word problem very well
- No data hiding
Characteristics of procedure oriented programming:
- Emphasis is on doing things(algorithm)
- 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
- Function transforms data from one form to another.
- Employs top-down approach in program design