Procedure-Oriented Programming.
What is Procedural Programming? [Definition]
Procedural Programming may be the first programming paradigm that a new developer will learn. Fundamentally, the procedural code is the one that directly instructs a device on how to finish a task in logical steps. This paradigm uses a linear top-down approach and treats data and procedures as two different entities. Based on the concept of a procedure call, Procedural Programming divides the program into procedures, which are also known as routines or functions, simply containing a series of steps to be carried out.
Simply put, Procedural Programming involves writing down a list of instructions to tell the computer what it should do step-by-step to finish the task at hand.
Key Features of Procedural Programming
The key features of procedural programming are given below:
-
Predefined functions: A predefined function is typically an instruction identified by a name. Usually, the predefined functions are built into higher-level programming languages (Links to an external site.), but they are derived from the library or the registry, rather than the program. One example of a pre-defined function is ‘charAt()’, which searches for a character position in a string.
-
Local Variable: A local variable is a variable that is declared in the main structure of a method and is limited to the local scope it is given. The local variable can only be used in the method it is defined in, and if it were to be used outside the defined method, the code will cease to work.
-
Global Variable: A global variable is a variable which is declared outside every other function defined in the code. Due to this, global variables can be used in all functions, unlike a local variable.
-
Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are grouped together to conclude a larger task first. Every group of systems then would have its own tasks finished one after the other until all tasks are complete.
-
Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions, subroutines or procedures. Parameter Passing can be done through ‘pass by value’, ‘pass by reference’, ‘pass by result’, ‘pass by value-result’ and ‘pass by the name’.
Advantages and Disadvantages of Procedural Programming
Procedural Programming comes with its own set of pros and cons, some of which are mentioned below.
Advantages
- Procedural Programming is excellent for general-purpose programming
- The coded simplicity along with ease of implementation of compilers and interpreters
- A large variety of books and online course material available on tested algorithms, making it easier to learn along the way
- The source code is portable, therefore, it can be used to target a different CPU as well
- The code can be reused in different parts of the program, without the need to copy it
- Through Procedural Programming technique, the memory requirement also slashes
- The program flow can be tracked easily
Disadvantages
- The program code is harder to write when Procedural Programming is employed
- The Procedural code is often not reusable, which may pose the need to recreate the code if is needed to use in another application
- Difficult to relate with real-world objects
- The importance is given to the operation rather than the data, which might pose issues in some data-sensitive cases
- The data is exposed to the whole program, making it not so much security friendly
Structure of POP method
Here is some problems in POP method like its difficult to handling data because it gives no importance to data. Dat means the information that are collected from user and after calculation new result come. If any one is familiar with C programming than he may recollect storage classes in C. In C, data member is declared GLOBAL in order to make 2 or more functions in the program. What happen when 2 or functions on the same data member. For example, when if there are 7 functions in a program and this become a global data member. Unfortunately, if the value of any global data member or that may key element than it will affect the whole program. It is a big problem to identify that which function is causing the problem.
Handling of data & functions in POP
One of the most important feature of C language is structure. Programmer use integer data, decimal point data(float), array data pack together into single entity by using structure. The reason of the popularity of structure was introduced first by c language.