Skip to content Skip to navigation

Connexions

You are here: Home » Content » Visual Tools for Problem Solving with M-Files

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

    • External bookmarks
  • E-mail the author

Recently Viewed

This feature requires Javascript to be enabled.

Visual Tools for Problem Solving with M-Files

Module by: Darryl Morrell

Summary: This module provides a brief introduction to the use of flow charts and pseudo code as aids in problem solving.

Using an abstract visual representation while developing a program structure is often a useful technique. Several different visual representations have been developed; one of the most comprehensive is UML. Two of the simplest are introduced in this module: flow charts and pseudo code. In both flow charts and pseudo code, elements of the problem solution are described using natural language statements that are visually arranged to show the structure of the program.

A flow chart represents elements of the solution to a problem as statements enclosed in boxes; the sequence in which use elements are performed is identified by arrows connecting the boxes. Figure 1 shows an example flow chart.

Pseudo code represents the elements of the solution to a problem as a sequence of statements. The statements are formatted to show the logical structure of the solution. Figure 2 shows an example of pseudo code.

The following example demonstrates the use of flow charts and pseudo code to develop the structure of a program that solves an engineering problem.

Example 1

The ACME Manufacturing Company is planning to manufacture widgets. There are two different manufacturing processes: one cost $10,000 to implement and can manufacture up to 1000 widgets, while the other cost $100,000 to implement and can manufacture up to one million widgets. In addition to the manufacturing cost, there is a fixed cost of $1 per widget (for packing and shipping each widget to the customer). Consider the problem of calculating the cost per unit to manufacture and ship a given number of widgets.

One way to solve the problem is to complete the following steps:

  • Get the number of widgets to be produced.
  • Determine the total manufacturing costs.
  • Determine the total fixed costs.
  • Determine the total cost.
  • Compute the cost per unit.

Figure 1 shows a flow chart that represents these steps. Figure 2 shows the pseudo code that represents these steps.

Figure 1: A flow chart for the widget production problem.
First Flow Chart
FirstFlowchart.png
Figure 2: Pseudo code for the widget production problem.
First Pseudo Code
Get the number of widgets to be produced.
Determine the manufacturing costs.
Determine the total fixed costs.
Determine the total cost.
Compute the cost per unit.

Having developed an initial solution, we can refine those elements whose implementation may not yet be fully defined. In this example, the manufacturing cost depend on the number of widgets to be made; if this number is less than or equal to 1000, the cost is $10,000, while if the number is greater than 1000, the cost is $100,000. We can represent this using the flow chart blocks in Figure 3. The diamond is a conditional; the branch of the flow chart that is actually executed depends on whether the conditional is true or false.

Figure 3: A flow chart for the manufacturing costs.
Flow Chart for Manufacturing Costs
MCFlowchart.png

Putting this conditional into the complete flow chart gives the flow chart in Figure 4. The conditional is incorporated in the the pseudo code to give the pseudo code in Figure 5.

Figure 4: The complete flow chart for the problem.
Complete Flow Chart
FinalFlowchart.png
Figure 5: Pseudo code for the widget production problem.
Complete Pseudo Code
Get the number of widgets to be produced.
if number of widgets > 1000
    manufacturing costs are $100,000
else
    manufacturing costs are $10,000
Determine the total fixed costs.
Determine the total cost.
Compute the cost per unit.

There are advantages and disadvantages for both flow charts and pseudo code. Advantages of using a flow chart include that it provides a strong visual representation of the program and that it is straightforward for novice programmers to use. The primary disadvantage of using a flow chart is that it is possible to create a flow chart that can only be implemented by "spaghetti code". Spaghetti code is considered extremely bad form for many reasons; in particular, it is hard to understand, debug and modify. The primary advantage of pseudo code is that its structure is clearly related to the available control structures in modern computer languages. Pseudo code has several disadvantages: it is not a very strong visual representation, and it is less straightforward for novice programmers.

Comments, questions, feedback, criticisms?

Send feedback