Implementing Sequence Structures
Of all of the control structures, we are most familiar with sequenced structures. We have been using sequence in the examples covered in earlier lessons. A sequence structure represents a process step. An important part of system theory is that there is one input to the process and one output. All control structures, including sequence, represent the processing step in systems theory. The systems theory rule of one input moving into a process and finally to one output returned is central to the correct use of control structures.
Flowcharts Example of Sequence Structures
The sequence structure is drawn on a flowchart with two arrows and a rectangle. One arrow points to the top of the rectangle and represents the entry point (input). The rectangle represents the process and within it a short text message should explain what that step will do. A final line will drop from the bottom of the rectangle and represent the exit point (output). In (Figure 5) a single sequence structure. Please note that the example structure is a template and is unlabeled whereas typically it would contain information on what this sequence structure would perform.
Figure 5: A Sequence Structure demonstrated in an actual application. The sequence structure includes an assignment where the msg variable will hold the literal "Hello World."
Common Sequence Structure Flowcharting Mistakes
Sequence structures are the easiest of the control structures to flowchart. Mistakes made on sequence structures usually have to do with forgetting to add both an input and output line to the top and bottom of the sequence structure rectangle symbol. A sequence symbol that only outputs or only inputs data is incorrect.
Figure 6: Example of valid and invalid sequence flow chart
Rules of Flowcharting Continued
Flowcharts are designed to provide a flexible graphical alternative to pseudo code for representing computer logic. With pseudo code, we have rules regarding the construction of pseudo code statements and recommendations concerning the formatting of pseudo code (i.e. certain statements should be indented to add clarity to the logic). Flowcharts also have rules that should be observed when using drawing structures. Flowcharting rules are a combination of requirements necessary to implement structures correctly and also to make the chart easier to read.
Below I have listed some of the important rules you will want to take in consideration when designing flowcharts. As with so many topics covered in this lesson, we cover only the fundamentals of flow charting. To complete your understanding of flowcharts would require some additional study and more practice that is asked for than with this lesson. One of the more popular software tools used to create flowcharts is Microsoft's Visio software.
- Never cross lines in your flowchart even if the positioning of the symbols leaves you little alternative. It may take high level of artistic effort to space your symbols to avoid having the lines cross but if you're structure is to be drawn to the rules of structured programming, lines cannot touch. Touching confuses the requirement of one input and one output.
- Each symbol should be labeled with information describing the activity of that symbol. For decision structures, which we will cover shortly, make sure each branch is labeled as to whether it represents the true or false outcome and the diamond symbol should include the Boolean expression. Sequence structures should have a text description of what is performed on that step.
- Complete flowcharts should always start with a terminator symbol labeled start and conclude with a terminator symbol labeled end
- If a flowchart needs to be drawn across multiple pages, as is quite frequently the case, the line drawn from the last symbol on the page should contain a off-page connector symbol (represented in flowcharts as a figure that is square on one side and pointed on the other -similar to the home plate on a baseball diamond) with a number contained within it. You should start the next page with the connector symbol and the corresponding connector number to indicate where the line continues from the previous page.