After the modules are known, each must be worked out in detail, and the design recorded in a form that the programmer can follow.

Modularization

Modularization is the division of the system into modules. A module is a part of the program that has a name, can be compiled separately, and has a defined interface. The benefits are that each module is easier to understand, modules can be built by different people at the same time, a fault is easier to find and fix, and modules can be reused. The design aims at modules that are highly cohesive and loosely coupled. The span of control is the number of modules that a module calls, and depth is the number of levels of control. The fan-out of a module is the number of modules that it calls, and the fan-in is the number of modules that call it. A high fan-in shows good reuse, and a very high fan-out shows that the module does too much.

Definition: Module. A named, separately compilable unit of a program with a defined interface that performs a specific task.

Design Structure Charts

A structure chart shows the hierarchy of modules and the data that pass between them. Each module is a rectangle. A line from a module to a lower one means that it calls the lower one. A small arrow with an open circle on the line shows a data item that passes, and one with a filled circle shows a control flag. A diamond shows a decision, that is, a conditional call, and a curved arrow shows repetition, a loop of calls. The structure chart is read from top to bottom and left to right, and the calls are made in that order. It is produced from the data flow diagram by identifying the central transform.

Flow Charts

A flow chart shows the logic of a module as a chart of steps. The symbols are an oval for start or end, a parallelogram for input and output, a rectangle for a process or a calculation, a diamond for a decision with two or more exits, and arrows for the flow. Flow charts help in detailed design and in explaining the logic, but they become unwieldy for large modules. Other forms of low-level design are pseudocode, which describes the logic in structured English, and decision tables.

Table 3.2: Symbols of a flow chart

Symbol Shape Meaning
Terminator Oval Start or end
Input and output Parallelogram Read or print
Process Rectangle Calculation or action
Decision Diamond Test with branches

Example 3.2: Flow chart for the largest of two numbers

Problem: Draw a flow chart that reads two numbers and prints the larger.

Solution:

  1. Start, then read a and b.
  2. Test whether a is greater than b.
  3. Print a if yes, otherwise print b, then end.

Result: The chart is shown below.

Common mistakes

  • Drawing a structure chart as if it showed the order of the program's flow like a flow chart.
  • Writing modules with a very large fan-out.
  • Making flow charts for every small module, which wastes effort.

Key takeaways

  • A module has a name, an interface and one clear task.
  • A structure chart shows the module hierarchy and the data and control passed.
  • A flow chart shows the logic inside one module.
  • Fan-in is the number of callers, fan-out is the number of modules called.

Practice questions

  1. What is a structure chart?
  2. What does a diamond mean in a flow chart?
  3. Define fan-out.

Answers to the practice questions

  1. A chart showing the hierarchy of modules and the data and control that pass between them.
  2. A decision with branches.
  3. The number of modules that a module calls.

Sources

  • Official BCA syllabus Advanced Software Engineering, course code 25BCA405DS01, Unit III