In this article we discuss about Usage of basic programming controlling structures and modularization. In programming, one of the main problems that developers face is the complexity and size of the applications. Working with such large and complex applications may result to following problems.
- Difficulties in coding, testing, debugging and implementing a larger application.
- Doing modifications to the product after the finalizing is harder.
- Difficulty faced by developers in maintaining the application and its files.
- Having even one error can stop the complete running process.
- Time period of developing is higher.
To overcome these negative aspects, modularization is introduced and what it does is, it divides bigger tasks of larger programs to smaller tasks. These tasks are called as modules and, converting larger tasks to smaller modules is called modularization or modular technique.
Identifying the Modules
First, we have to identify each possible module from the main program. There is no exact method of doing that, because programs are not identical to each other. Following points describe how to identify modules in a program.
- You can create modules that handles program data.
- You can create modules that handles program services.
- You can create modules that handles program functions.
- You can create modules that handles program logics.
After creating main modules as above, you can re divide them indo sub modules for the development aspects. For this, you have to combine programming rules and regulations with the modularization points as above mentioned.
- set totalPayroll to zero
- [Get_Employee_Pay_Values] (first)
- WHILE not EOF [Process_One_Employee]
- DISPLAY totalPayroll
After modularization, you can use it as step by step process flow for the complete outcome of the program. You can use Algorithms or Pseudocodes for this step. Main advantages of this step by step method of usage are:
- Anyone including developers and clients can understand both problem and solution.
- In developing the program, each statement simply can be converted to a program statement.
- It can be part of documentation and assist in program maintenance.
Example: Problem statement: Bus ticketing payment
Step by step solution.
- Does the passenger have a season card?
- If yes, go to step 10, else go to step 3.
- Enter passenger the destination to the system.
- Take fee amount from the passenger in cash or card.
- Enter payment data to the system.
- Click on save button.
- Print the receipt by the machine.
- Provide receipt to the passenger.
- Exit from the final interface.
- Enter season data to the system.
- Validate data.
- If successful go to step 12, else go to step 3.
- Save data to the system.
- Exit from the final interface.
- Mark data in the season card.
- Provide season card back to passenger.
In programming, control structures analyze decisions to the final outcome of the program. It is based on parameters regarding each program. They are very important elements in developing software and must be declare and implement in the beginning of the development.
Algorithms and pseudocodes can be used to analyze and identifying where control structures are required in the developing process of the program.
There are three types of control structures.
Decision Control Structures
Decision control structures are used to clarify the next steps to be executed and the criteria it depends upon. In this criterion, you can use one or more Boolean expressions as for the evaluation process resulting “true” or “false”. One set of statements and functionalities is implemented and executed if the criteria is “true” and if the criteria is “false”, a different set is executed. You can take “if statements’ as an example.
Selection Control Structures
Selection control structures are used to analyze program sequences depends upon the result of a specific selection. For example, a program provides many options to be selected by the user. The statement that executes next depends on the option selected by the user in the previous step. Switch statements and case statement are often used in this type of structures.
Repetition / Loop Control Structures
Repetition control structure is used to repeat a set of statements many times in a program. The number of repetitions can be stated as a static value before it starts or can be setup to depend on the value provided by the user or by random expression. For statement, while statement and dowhile statement can be taken as examples for this type of structures.
Usage of basic programming controlling structures and modularization was done. Read Our Previous articles here.