Flowcharts

  • Intro

    An algorithm is a set of steps for completing a task that can be written down and implemented. Algorithms are made up of actions/steps, decisions, inputs, and outputs. For example, a cake recipe can be thought of as an algorithm for making cake. Such a recipe describes inputs, actions, and outputs. It may also include decisions such as whether or not to include nuts. Ideally, algorithms followed properly produce reliable outcomes. For example, if a good cake recipe is followed properly, a good cake will result. An algorithm prepared for a computer program describes how to take known inputs and convert them into specific outputs by following a set of specific actions.

  • Symbols

    Flowcharts are made up of the standard symbols shown in Figure 1. The use of standard symbols means that users do not need to be taught different sets of symbols every time they read a flowchart.

    Functional Areas

    Each one of these symbols plays an important role in flowcharts and programs that can be implemented from flowcharts. Within a flowchart, actions (process steps), flow arrows, and decisions are fundamental building blocks that can be combined in a variety of ways.

  • Basic Guidelines

    Functional Areas
  • Assignments vs. Equalities

    A flowchart is simply a visual representation of an algorithm. When constructing algorithms, it is often necessary to do math and assign the results of this math to variables. In other situations, it is necessary to test whether equality between two values exists. Assignments and tests for equality are fundamentally different operations with very different purposes.

    During assignment, the result of the calculation on the right side of an equals sign is assigned to a variable on the left of the equals sign. For example, consider the assignment "Pay = Hours * Rate". In this assignment, Hours is multiplied by Rate, and the result of this calculation is assigned to the Pay variable on the left of the equals sign. Assignments always go from right to left. That is, the operation on the right side of the equals sign is completed. Then the result is assigned to the variable on the left of the equals sign.

    A test of equality, on the other hand, is a logical test that evaluates whether two values are equivalent. Like all other decision diamonds, tests of equality return either true or false. With a test of equality, if what is on the left and right side of the equal symbol are equal, the equality returns true; otherwise, it returns false. Tests of equality are part of conditional logic. For example: If Today = "Friday", Then Balance = Balance - 50. In this case, we check to see if the value fo the Today variable is equal to "Friday". Then, if it is, we take 50 away from our Balance and then assign that new value into our Balance variable. The left side of this statement (the "if" portion) is a test of equality, while the right side (the "then" portion) is a value assignment.

  • Variable Names and Variable Legends

    In general, you should use short variable names in flowchart symbols to keep flowcharts compact and easy to draw. Thoughtful selection of acronyms or brief names can help you and subsequent readers remember what the brief names represent. For example, NP for Net Pay is much easier to remember than Z or some other non-descript variable name for Net Pay. These same short variable names can be used in the code that correspond to the flowchart as well.

    Variable names should not be separated by spaces because computer programs think of variables as a single entity and will interpret a space as the end of a variable name. For example, NP, Net_Pay, and netPay are fine as variable names but "Net Pay" is not.

    The creator of the flowchart should include a variable legend to show short variables and their associated meaning so the reader can understand what the short names mean. Later on, if a program is developed, the developer will add field labels to the user interface (e.g., spreadsheet) to help the user know what to put in each specific field.

  • Logical Flow Control Structures

    Programs typically consist of three fundamental flow control patterns: sequence, selection, and repetition. Figure 2 shows these fundamental patterns. With a sequential pattern, one step is completed followed by a next step and so on. With a selection pattern, the answer to a question causes a branch in the process. Thus, some steps are skipped under certain circumstances. As we define a decision, it will return either true or false. Thus, if the decision returns true, one branch is taken. If the decision returns false, the other branch is taken. The repetition flow control structure (also known as loop) allows one or more actions to be repeated until a condition is met.

    Functional Areas
  • Selection (Decision) Structures

    Conceptually, every If-Then structure has four parts: diamond (logical test), true branch (do-if-true), false branch (do-if-false), and end (represented by the connection circle). The connection circle is necessary for correct flowchart structure

    The If-Then-Else structure does one thing if the decision returns true and does a different thing if the decision returns false.

    Functional Areas

    If the Else (False) condition is omitted, the If-Then-Null-Else structure is used. If the logical test is true, then the do-if-true action should be taken; otherwise no action is taken.

    Functional Areas

    The Nested selection structure in the figure below is another common selection structure. Depending on how the first decision is answered, the flow can go to additional decisions.

    Functional Areas

    a Select Case (sometimes called Switch Case) decision structure is another option. If decision 1 is true, then path 1 is executed and the selection process finishes; otherwise, decision 2 is tested. If decision 2 returns true, then path 2 is executed and the selection finishes. If decision 2 is false, decision 3 is tested. If decision 3 is true, then path 3 is executed and the selection finishes. If all previous decisions are false, the Case Else path is executed. Notice that the number of paths equals the number of decisions. This type of selection structure can have as many decisions as needed.

    Functional Areas
  • Repetition (Loop) Structures

    With a repetition flow control structure, a step or set of steps is repeated until a certain condition is met. The repeating code is sometimes referred to as a loop or iteration . The While loop (Figure 6) is the most common type of repetition structure. A While loop tests a condition first. If the test returns false, then a process is executed. Then the flow loops back to the decision again. Each time the test returns false, the process is done again. If the test returns true, the algorithm exits the loop. The While loop can be thought of as a repeating If-Then-Else statement.

    The Until loop is very similar (but opposite) to the while loop. However, rather than loop while a condition is false it loops until a condition is false. While and until loops are interchangeable by reversing the condition. For example, "loop while x > 0" is conceptually the same as "loop until x = 0".

    Functional Areas
  • Inputs

    Inputs can come from two sources: from users or from data stored in a setup section. Values stored in setup storage can reduce the need to re-input values each time the program is run. For example, if shipping rates rarely change for a shipping office, these rates could be stored in a setup section so that the user does not need to enter this data each time the application is run. When designing a flowchart, the designer should determine which inputs should be entered every time and which, if any, should be stored in setup storage. As shown in Figure 7, when regular inputs are required, the "Input" word should be used. When input from setup is required, the "Input-from-Setup" phrase should be used.

    Functional Areas

    Initial Inputs and Control Inputs

    Inputs may be obtained at the beginning of an algorithm or may be obtained after the algorithm has begun in order to control the execution of the program.

    Consider the two flowcharts in the figure to the right (or below). Flowchart A is a flowchart with a sequential flow structure that takes inputs of Employee name, Gross pay, and a Tax rate and calculates Tax and Net pay. In this case, all inputs are obtained at the beginning of the process. Beyond this initial input, the user answers no questions to control the execution of the process. Because of this, no specific Prompt message is included in the flowchart input symbol.

    Functional Areas

    On the other hand, if a process requires initial input at the beginning of the process and then later a question must be answered to control program execution, a Prompt output should be used to signal clearly to the user what additional input is required. For example, notice in Figure 8, Flowchart B, that a loop has been added to allow the algorithm to repeat multiple times. In this case, after Tax and NP have been calculated for the first employee, the Prompt explains what input the user must enter to repeat the process for another employee. The Prompt "Process more payroll? y or n" is added to guide the user. Once the user inputs the response, the response is evaluated in the decision box so that the algorithm can behave appropriately. Notice that when a Prompt is used it should be followed by an Input that specifies the name of the variable required from the user.

  • Outputs

    Three types of outputs exist for flowcharts: Display, Print, and Prompt.

    The "Display" word is used when output is sent to the computer screen. The "Print" word is used when output is sent to a printer. The "Prompt" word is used when it is necessary to ask the user for some specific input after the program has begun.

    When Inputs Should Also be Included in the Output Symbol

    It is often helpful to include some inputs in the output symbol even though the value of those inputs remains unchanged by the algorithm. These flowcharts take the inputs of Employee name, Gross pay, and Tax Rate and create Tax and Net pay outputs. Notice that the three inputs are also listed as outputs in the flowchart even though they have not changed. The reason to include them is that the output needs to be associated with these values to mean anything to the user. Tax and net pay need to be associated with the person's name, gross pay, and tax rate to be usable. The unchanged inputs in an output symbol are surrounded by parentheses to differentiate them from the other outputs.

    Functional Areas
  • Termination Tables

    Care should be taken to design your algorithm correctly so that a loop terminates at the right time based on a changing value of a variable. The loop should not repeat too many times or too few times. To get the termination condition correct, it can be helpful to track the changing values of variables within the algorithm with one or more test cases. You can construct a table to show the value of variables as the algorithm progresses to make it easier to visualize changes in variables as a loop repeats. This approach can help you determine a loop termination condition that is appropriate for a variety of loop-based algorithms.

    When constructing such a table, the order of the columns in the table should correspond to the order of components in the loop in order to avoid misleading values in the table. The loop termination table below is for the algorithm to the right (or below). The first row in the table represents the initialization of the variables to values before the algorithm enters the loop. The first (left-most) column corresponds to the first decision diamond that begins the loop. The second column corresponds to the next step [Sum = Sum + Count] and so forth.

    Functional Areas
    Functional Areas

    When developing a loop termination table, you should select some reasonable example variable values. The loop termination table above was constructed for a test case when N equals six. From the table, it can be seen that the logical test of "Count > N?" shown in the flowchart is correct because the loop terminates when the value of 6 has been added to the sum. Had the loop terminated before six was added, it would have terminated too early.

  • Order of Operations

    Most programs include math formulas in some form. Formulas may contain a mixture of parentheses, pluses, minuses, multiplications, divisions, and powers/radicals. Algorithms in flowcharts and programming languages use standard algebraic rules for the order of operations in mathematical formulas. This avoids unnecessary characters in formulas. The figure below shows the order of operations.

    Functional Areas
  • Flowcharts in Practice

    Flowcharts are a diagram-based conceptualization of actual business processes. Business processes comprise "what we do" as a business and "how we do it." Your business processes determine your cost and efficiency of doing business. However, flowcharts also represent the structure of the IT systems, or computer programs, that support those business processes. Essentially, flowcharts are the "glue" that brings together business processes and the organizational systems that support them. They are a translation mechanism.

    There are many questions you may still have about flowcharts. For example, how should they be formed? Who decides? Should a flowchart determine the business process or should the business process determine the flowchart? The answer to that last question is: both. Typically, flowcharts (and many other related diagrams) are created in two sets: 1) those describing current business processes, and 2) those conceptualizing how those processes might be improved to be more efficient. The role of the IS professional (and systems analyst in particular) is to research current people and processes in order to create the first type, and then be creative in coming up with the second type. Your ability to create new and unique processes can be your own personal strategic competitive advantage.

    Lastly, keep in mind, one of the favorite tasks that recruiters give to new college graduates (of any business degree program) during the interview is to create a flowchart based on a written narrative. Be ready to create one on a moment's notice!

  • Videos

    The following videos about flowcharting are a good place to start. However, the reading following the video contains additional examples and practice problems. It also contains more detail that may make the concepts easier for you to understand. Use your discretion as you decide which materials to use to help you learn.