|
Part 2ýPutting Theory into Practice
by George Martin
Start ý Digging
In ý Making Changes ý Try
It Out ý Sources and PDF
As I stated last month, using Nassi Schneiderman
flowcharts helps me develop a more structured design. And, I find
that the more a design is structured, the more manageable it becomes.
I hope you had a chance to look at the
references from Part 1. If you did, you probably noticed that I left
out case, or switch, constructions. I thought it would be too much
to include, as I already had enough to cover. But when I started writing
the second part of this series, wouldnýt you know that one of the
first constructs I needed was best shown as a case construction. So,
allow me to back up a little and cover the case and switch constructs.
Depending on a value of a variable, different
tasks may need to be performed. Letýs say that the keyboardýs input
of 0 to 9 is to perform 10 different functions. Listing
1 is an example of what you could
code until all the cases are covered.
Most languages have a switch or case statement.
And in C, it goes something like what you see in Listing
2.
The Nassi Schneiderman construction can
be seen in Figure 1.
|
|
| Figure 1ýHere you can see the
switch, or case, construction set up as a Nassi Schneiderman
chart. |
I only diagrammed the 0, 1, and 2 processes
and added a default process. But, you can see that this construction
has only one input and one output. And depending on the switch variable,
only one set of processes are followed.
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |