The use of Nassi-Shneiderman charts and supporting tools in software engineering education

The use of Nassi-Shneiderman charts and supporting tools in software engineering education

CompwEduc.Vol. II, No. 4, pp.267-279, 1987 0360-I 315/o $3.00 + 0.00 Printed in Great Britain Pergamon Journals Ltd THE USE OF NASSI-SHNEIDERMAN C...

879KB Sizes 0 Downloads 63 Views

CompwEduc.Vol. II, No. 4, pp.267-279, 1987

0360-I 315/o $3.00 + 0.00

Printed in Great Britain

Pergamon Journals Ltd

THE USE OF NASSI-SHNEIDERMAN CHARTS AND SUPPORTING TOOLS IN SOFTWARE ENGINEERING EDUCATION M. R. WOODWARD Department of Computer Science, University of Liverpool, P.O. Box 147, Liverpool L69 3BX, U.K. (Receiued

12 Seprember 1986)

Abstract-In 1973 Nassi and Shneidennan proposed a new form of flowchart which was advocated as being better suited to the practices of structured programming. It is argued that Nassi-Shneiderman charts (N-S charts) provide a convenient common framework for the communication and practice of other widely accepted ideas concerning software development. They can for example be used to promote top-down design, structured implementation, thorough testing and graphical documentation. This paper relates experiences using N-S charts in a University educational environment and describes some tools which have been developed to support use of the charts. Key word-Nassi-Shneiderman education.

charts; software tools; testing; documentation;

software engineering

INTRODUCTION

For a number of years the author has been in the fortunate position of presenting an introductory programming course in a high level language to a large class of first year undergraduates at Liverpool University. This means that as well as merely imparting knowledge about a particular language and computer system, an entire pattern of work can be moulded (at least for those with little or no previous experience of programming) which will hopefully be carried through the students’ University careers and beyond. It is possible for example to influence the approach to program design, the style of program construction and the perception of the roles of testing and documentation. At the outset a decision was made to use Nassi-Shneiderman charts (N-S charts) [ l] to introduce the notions of modular, top-down design, pseudo-code and structured programming, since the charts provide a notation independent of any particular programming language. See Fig. 1 for N-S charts of the sequence, selection, repetition and block structures. Since their introduction N-S charts have gradually gained in popularity as their virtues have become apparent[2,3] and now a number of programming textbooks for the commonly used languages, Basic[4], Fortran 77[5] and Cobol[6] make use of the charts in the development of example programs. Varying modifications to the original form of N-S charts were proposed by Chapin[7] and Lindsey[8]. An additional consideration has been the construction of tools to promote use of the ideas. It was felt that provision of a tool which students could use to obtain automatically the equivalent N-S chart of any given valid program in the high-level language would have a beneficial impact. By being able to obtain easily a two-dimensional chart of a completed program, suitable as part of the program documentation, the use of N-S charts for program design is reinforced. Such a tool has been developed for programs in Algol 68 and Fortran 77. In their third and final year of undergraduate studies, Computer Science students at Liverpool University may opt to take a course in Software Engineering. This in-depth course places tremendous emphasis on techniques to assist the software development process for building reliable software. Some of the methods are a reflection of the “state-of-the-art” and although relevant and of interest to the students, they also have the disadvantage of opening a “credibility gap” between what is taught and what can be done with available facilities. The gap is caused in part, by the lack of suitable tools for many of the ideas discussed in the course. 267

M.

268

R.

k%DDWAIlD

!_____________________________!

!_____.._____________! , ,

First process

8

1

! ,

!

1 !___________________! ! ! ! Next process ! ! ! !___________________!

! IF

!

condition

1

! ? !___________! !__________-! 1 ! TRUE ! FALSE !_____________________________! 1 ! I ! THEN ELSE process ! process ! ! ! !_____________________________!

1 ! ! 1 1 ! !

SELECT106

SBQUEHCE

!______________________!

!____________________________!

!

I

I

!

! FOR i FROM bottom TO top ! WHILE condition ! DO

! ! 1

! BEGIN !_+______________! ! ! ! ! ! Process ! ! 1 !___________..____! ! END !______________________!

!

I !______________________! t ! ! 1 ! ! Loop process ! ! ! !____________________________!

! I I 8

BLOCK

REPETITION Fig. 1. Nassi-Shneidennan

charts of primitive structures.

As a partial step towards remedying this situation and also as an example for case study in the Software Engineering class, a simple testing system based on the N-S chart representation of programs has been constructed. The tool enables students to run Algol68 programs with test data and obtain, as well as normal output, an N-S chart with a frequency count of how many times each process box has been executed. Details of the N-S chart.tools are given in the next section and in section 3 the use of N-S charts and the associated tools is discussed. In the final section the ideas and tools referred to in this paper are reviewed in relation to work by others and plans for the future are outlined.

2. THE

SUPPORT

TOOLS

The tools that have been developed can be thought of as forming a static system and a dynamic system. The dynamic system collects information about a program run and incorporates it into the N-S chart, whereas the static system merely produces a chart of a given source program. In implementation much code is common to both systems. In the following subsections brief details are given of the user’s view of the two systems, their implementation and certain features specific to the languages involved. 2.1 The static system Users of the undergraduate use the command:

teaching machines at Liverpool University (three VAX 11/78Os) may NSCHART

(language)

where (language) is either ALGOL68 or FORTRAN77. The system will ask if the user wants output to appear on the screen or to be sent to a specified file. If output is to a file, the user has to decide what width of chart output is required. Two options are available, SCREENWIDTH

Software engineering education

269

PROGRAM GRADES l l

PROGRAM TO TOTAL MARKS

l

CHARACTER NAWE"25, RATING*10 INTEGER NSTUDS, MARKl, MARK2, MARKS. NARKI, MARK5, TOTAL READ l, NSTUDS PRINT l, 'NUMBER OF STUDENTS =', NSTUDS DO 10 N = 1, NSTUDS READ l, NAME, MARKl, MARK2, MARKS, MARK4, MARK5 TOTAL = MARK1 + MARK2 + MARK3 + MARK4 + HARK5 IF (TOTAL.GE.450) THEN RATING = 'EXCELLENT' ELSE IF (TOTAL.GE.~E~~) THEN RATING = 'PASS' ELSE RATING = 'FAIL' END IF PRINT *, NAME, MARKl: MARK2, MARK3, MARK4, MARK5, 1 'TOTAL', TOTAL, ', RATING 10 CONTINUE END Fig. 2. An example Fortran 77 program.

which is 80 characters wide and PRINTERWIDTH which is 132 characters wide. The system asks the user to specify a program source file for which an N-S chart is then produced. The N-S chart of more than one program can be obtained in one run of the system by specifying additional filenames when prompted. A small example Fortran 77 program is given in Fig. 2 and its corresponding N-S chart produced by the system is shown in Fig. 3.

______________________________________~~~~~~~~~~~~~~~~~

!_______________________G

I ! ! l I ! + PROGRAM TO TOTAL MARKS I 1+ ! ! CHARACTER NAME"25. RATING+10 I ! INTEGER NSTUDS, MARKl, MARK2, MARK3. MARK4, MARK5, TOTAL 1 , READ *, NSTUDS 1 1 PRINT l, 'NUMBER OF STUDENTS =', NSTUDS !_______________________________________~~~~~~~~~~~~~~~~~~~~~~~_~~~~~~~~~~~~~~_~ I ! DO 10 N = 1, NSTUDS ! ! 1 !_________________-_______-_________________~~~~~~~~~~~~~_~~~~~~~~~~~___~ I 1 ! READ *, NAME, MARKI, MARK2. MARK3, MARK4. MARK5 I I ! TOTAL = MARK1 + MARK2 + MARK3 + MARK4 + MARK5 I !_______________________________________~~~~~~~~~~~~~~~~__~~~~~~~~~~~~~_~ 9 ! , IF (TOTAL.GE.450) THEN r) I t 1 I !_________________________________! !________________________-________! I I 1 , ! TRUE FALSE !_____________________________________-_~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! 1 I ELSE IF (TOTAL.GE.380) ! ! RATING = 'EXCELLENT' I 1 I ! THEN 1 I I l ? , , !_______________! !_______________! I I I 1 I TRUE FALSE ! , !___________________________________! ! I I t I I 1 I ! RATING = 'PASS' ! RATING - 'FAIL' ! !_____________________________________--~~~~~-~~~~~~~~~~~~~~~~~~~~~~~___~ ! 1 1 t PRINT l, NAME, MARKl: MARKP, MARK3, MARK4, MARK5, I I I 'TOTAL', TOTAL, ', RATING I 1 I 10 CONTINUE !_______________________________________~~~~~~~~~~~~~--~-~----~~~-----~~-----~~~ 1 ! END !_______________________________________~~~~~~~~~~~~~----~-----~~-----~~----~~~~ 1

PROGRAM GRADES

Fig. 3. N-S chart for the example Fortran 77 program.

WOODWARD

M. R.

270 PROGRAM BEGIN

1

grades

A program

to total

marks

and

then

grade

the

1

tots 1.

STRING name, rating; [ 5 ] INT mark; INT total; WHILE student name ( or press RETURN to quit print CC "Enter read (( name, newline 1); UPB name /= 0 DO 5 marks for ", name. l):-, newline )); print (( "Enter read (( mark, newline 1); print (( newline, name 1); total := 0; FOR i TO 5 DO total +:= mark [ i ]; print ( * w + whole ( mark OD; IF ELIF ELSE FI;

total total

print

(( w

>= 450 >= 380

Total

THEN THEN

=

rating rating rating

", whole

[ i 1. 0

:= u := u := w

):",

newline

1);

1 1

Excellent" Pass" Fail"

( total,

0

). rating,

newline

))

OD END FINISH

Fig. 4. An example Algol 68 program.

2.2 The dynamic system In place of the normal LINK and RUN commands of VAX/VMS, new commands NSLINK and NSRUN have been made available at Liverpool University to produce N-S charts with dynamic execution counts for Algol 68 programs whenever they are run. If an Algol 68 program has been compiled successfully then using NSLINK instead of LINK will perform the necessary linking with the N-S system. Any additional object files or libraries required by the user’s program may also be specified on the NSLINK command, just as they would have been when using LINK. Subsequently whenever the Algol 68 program is executed using NSRUN instead of RUN, the user’s input and output is as normal, but in addition, an N-S chart is produced with the number of executions of each process box during the run indicated in the top right hand corner of the box. Also a message is output giving the number of boxes, the number not executed and the percentage covered in the current program run. An example Algol 68 program is given in Fig. 4. For each one of a number of students, the program reads five marks, adds them and grades the total. Some sample output from NSRUN applied to this program is given in Fig. 5. On this occasion, the data for the run consisted of two students, one with a rating of “Excellent” and one with a “Fail” rating, as can be seen from the execution counts of the appropriate boxes. 2.3 Implementation Internally each of the primitive structures of Fig. 1 is considered as having a corresponding binary tree representation as in Fig. 6. When a given source program is parsed a binary tree version of it is developed with the leaf nodes containing actual program statements and the other nodes representing the relationships between the leaf nodes in accordance with the notation of Fig. 6. Displaying the N-S chart then corresponds to walking through the tree in the appropriate fashion and enhancing the view of the nodes with the requisite cosmetic features. If at any stage in producing the N-S chart the width of a process box becomes too small to insert program statements, the current node is marked as a “wait” node to indicate that its entire subtree

Software

!____________________________-

engineering

education

271

________________________________________~~~~~~~~~~

,

1

! PROGRAM grades !_______________________________________~~~~~~~~~~~_~~__________~~_~~~~~~____~-~ ! BEGIN

! ! 1

!_______________________________________~~~~~~~~~~~~~~~~~~_~~~~~~~~~~~~---! 1 !

1 ; { A program to total marks and then grade the total. ) I I ! STRING name, rating; ! 1 ! [ 5 ] INT mark: ! INT total: ! !_______________________ ___________________________--___________~~~~~~~~~___~ ! 1 ! I ! WHILE !

!_____________________________________________________~~~~~~~~~~~~~~

! ,

I

! ,

! 1 0 ! ! 0 1 1 ! 8 ! 1 ! ! 1 I ! ! 1 I I ! t I 1 1 ! 1 ! f ! I ! ! ! !

( or

press

RETURN

to quit

):I(,

!___________________________________________________~~~~~~~~~~~~~~~~

1

!

3

! print (( "Enter student name ! newline 1); ! read (( name, newline )); ! UPB name /- 0

!

!

t I I !

DO

8 ! print

! read

5 marks for CC "Enter (( mark, newline 1);

! print ! total

(( newline, := 0;

name

((,

name,

(I:l(, nevlins

1);

!___________________________________________~~~~~~~~~~~~~~~~~------~ t ! FOR i TO 5 ! DO I

!_______________________________________--------------------!

I

!

!

! total ! print

!

I !

1);

2!

! 1 10

+:= mark [ i 1; ( I( w + whole ( mark

[ i 1. 0

) )

! I !

!_______________,________________________~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1

!

IF

!

2!

I ! tot.31 >= 450 1 ! ? !______________________________! !_______________________________! I I I I FALSE TRUE !______________________________

____________________________________!

I ! ELIF ! 1 ! I 1 , total >- 380 ! ? ! ! , !______________! !________----em! I I , 1 I TRUE FALSE t !_________________ __________----em! t I 1 ! 0 ! I ! ! rating := ! rating := , II Fail" ! ‘I Pass" ! ! !_______________________________________~~~~~~~~~~~~~~~-~----------! I 2! ! print (( v Total = I(, whole ( total, 0 ), rating, nerline )) !

!

! rating

1

:=

v

Excellent"

! END !_______________________________________~~~~~~~~~~~~~~~~~~~~~~~~~~-~~~--~~~~---~ 0 ! FINISH !_________________________________________________~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Number of boxes Number not executed Box coverage

= 14 = 1 = 92.86%

Fig. 5. N-S chart with execution

counts for a run of the example Algol 68 program.

I 1

! I

272

M.R.

WOODWARD

?

/\

/\ First process

Next process

+

condition

/\

SEQUERCE

THEN

ELSE

process

process

SELECTIOl

B

I

/*\ loop process

100p

control

/\ Process

Empty

BLOCK

REPETITION

Fig. 6. Binary tree representation

of primitive structures.

is still to be printed. A message of the form “- - > BOX [ . . .I.,” is displayed in place of the program statements referring the reader to the n th overflow box of the current box, whose number is contained within the square brackets. Overflow boxes are printed using the full width of the display when printing of the current box has been completed as much as possible. In the dynamic part, the supplied Algol 68 program is instrumented by inserting a probe: -at the start of each procedure body, -after each BEGIN, THEN, WHILE, DO, IN and CASE clause comma. The probes merely collect information about the number of times flow of control passes through these points. The first two probe insertion points enable the monitoring of entry into procedures and blocks and the remaining insertion points are the minimum number required to permit branch coverage monitoring within a block or procedure[9]. For each probe point the execution count on termination of a program run is associated with the corresponding node on the binary tree. In general, the execution counts of other nodes are either inherited directly from the parent node or are calculated simply from the parent node and the other sibling node. For example, if the number of executions of a conditional clause is known to be x say, deduced from knowledge of the parent structure, and the number of executions of the THEN part is y say, determined by direct monitoring, then the number of executions of the ELSE part is easily calculated to be x - y times (see Fig. 7). Similar reasoning can be applied to the CASE and loop structures. ?

condition ( x times

( x times

+

)

( x times

1

)

/\ THEN

ELSE

process

process

( y times

)

(x-

y times

)

Fig. 7. Rule for determining execution counts in a conditional clause.

Software engineering education

2.4 Language specific features of the N-S

273

tools

Once the internal binary tree version of a source program has been constructed the display of the basic sequence, selection and repetition structures is independent of the underlying language. However, certain aspects of the tools do reflect particular features of the languages involved and they are the concern of this section. Both the static and the dynamic N-S tools for Algol68 may be used on the separately compilable DECS modules of Algol 68 RS[lO] as well as main program modules. Procedure bodies are explicitly contained within a box of their own and internally are represented by the binary tree shown in Fig. 8. The internal form of the CASE statement is also given in Fig. 8. Example output illustrating both a procedure and a CASE statement is given in Fig. 9. One particular feature of Algol 68 which makes the construction of charts of special interest is the fact that clauses may deliver values and be used in any position where an object of that mode is appropriate. For example, the boolean serial clause in the Algol 68 conditional: IF boolean-serial-clause THEN process 1 ELSE process 2 FI may have its own structure delivering as the last item a TRUE or FALSE value. In such an instance the boolean serial clause is represented by a separate box nested entirely within the choice part of the N-S chart of the conditional unit. This agrees with the charting convention proposed by

P

/\ PROC body

PROC heading

PROCEDURE

f\

chooser clause

/‘\

process

1

process

/‘=, 2

\ . \

\

/>\ process

n

OUT

clause

CASE

Fig. 8. Binary tree representations of Algol 68 PROC and CASE.

274 BOX

M. R.

WDODWARD

[lj

!___________________-___________________-__-_____________________~~~~~~~_~~~~~~~ ! PROGRAM example !_____________-_____-___-_-____________________________________________________! ! BEGIN I !____________---__________-_______________________________________________! , ! ! ! PROC day = ( INT d ) STRING:

1 I 1

!

I I

! I

!__________________________-______________________~~~~~~~~~~~~~~~~~~~~ ! CASE

I

!

8

, I !

! I ? ! !____________________________--______-____~~~_~~~~_~~~~~~~~~~~~~~~~~~~~~~~~ 1 9 1 >l !

1 I

1 !

! !

9 !

!_____________________________________________~~~~~~~~~~~~~~~~~~~~~~_~ "MON", ! ! 2 ! >2

1 !

!_______________________________-_________--_____________! ! "TUE", ! 3 ! >?J

I

! 1

! I

! 1

I t

1

,

!_______________________---_____________-----! 9 , ! "WED", 4 >4

1

1

!

1 I ,

,

I

!

1

I

t

9

I

1 ! "THU", ! 5 ! >5 9 ! , !____________________! I ! 1 ! "FRI", ! 1 ! ! ! 1 1 1 ; r;;";" ____________________________________________________________________! d TO 7

,

!

!____

8

, ! !

! FOR ! DO I ! 1

!

!_________________________-_____-_________________________________________!

!__________________________________________________________________! ! ! print ( day ( d ) + w " )

! END !____________________________________________-_________________________________! ! FINISH !_____________________________________________________~____~~__~~~_~~~~~~~~~~~~~

BOX

I

!________________________________!

!

I

I

!

d

1 ! ; I ! I

I ! !

[l.l]

!____________________________________________________________________________-!

>6 6 ! !______________________________________________________________________~~~~~~~~, ! "SAT", ! >I 7 ! , !__________________________________________________________________ I "*+*" 1 ! "SUN" 1______________________________________________~~___~__________~~~_~~~~~~~~~~~~~

I t ! I

Fig. 9. NSCHART output showing PROC and CASE.

Lindsey[8] who considered such situations of structure charts yielding values. As an example the N-S chart form for the following program fragment: IF IF stack ISNT nilstack THEN top OF stack = value ELSE FALSE FI THEN pop (topvalue, stack) ELSE print (“No change to stack”) FI is given in Fig. 10. Similar considerations apply to loops with a WHILE part which involves structure where a separate box, right justified, is used to display the actual WHILE clause. In fact in the dynamic tool, the WHILE part is given its own box, even if it only contains a simple sequence of statements, to show that as well as controlling the circumstances under which the loop body is repeated, it

Software engineering education

275

I I

IF

I

! I I 9 l

!_______________________________________------_____________! I ! IF 1 stack ISNT nilatack

t ! !

! !____________r_____________! I TRUE

?

I I

!____-______________________!

I

! ! FALSE !_________c__r__________________________~~~~~~~__~__~~_____~ t I ! top OF stack = value ! FALSE ! ! !_______________________________________~~~~__~__~~_~~~~~~_~

I ! ! 9 I I

I !

I 1 0

?

!______________c________________!

!________________________________!

I , TRUE FALSE !________________________________________~__~~_~~__~_____~___~__~~_~~~ 1 ! ! pop ( topvalue, stack ) ! print ( “No change to

1

I

I

I

stack”

)

i !

!______________________________-_________________________-______--_--!

Fig. 10. Example of boolean serial clause with structure.

is also itself a repeated clause. As an example the N-S chart form of the following program fragment: WHILE IF stack ISNT nilstack THEN top OF stack / = value ELSE FALSE FI DO pop (topvalue, stack) OD is given in Fig. 11. The decision parts of loops and conditional clauses are not the only place where structures may deliver values. However, in other circumstances the tools will normally treat such structures as sequential. For example the following program fragment: x:= Y :=

2 * IF a > b THEN a/b ELSE b/a FI; 0

will generate the chart of Fig. 12. !___________________________-__-________________________________! ! ! WHILE I I , ,

t 1 ! ! ! I I ! ! DO ! , I

1 1

!_________________________________________-___-_____-____! I ! IF I stack ISNT nilatack

! !

!_______________________________________~~~~~_~~~~~~~~~__~ , 9 ! top OF stack /= value ! FALSE , I !_______________________________________-__-__-__-__---__!

! 1 !

I I 9 ? !_________________________! !__________________________! f ! ! ! FALSE TRUE

t !________________________________________________--_---_-! l ! pop ( topvalue, stack )

8 I !__________________________________________~~~~~~~~~~~~~~~~~~~~~~ Fig. 1I. Example of WHILE clause with structure.

I

1 !

M. R. WOODWARD

276

!___________________________-___-_---_---~~~~~~~~~~~~_~ 8

,

.x:=2'

!

!

!___________________________-__--__--___-_____________!

iF

,

1 a > b 9 ? !________________________! !________________________! 1 1 , TRUE FALSE !_______________________________-__--______~~~~~~~~~~_~ ! a/b ! b/a !_____________________________---___-_-_______________! ! ! y := 0 !_______________________________________~~~~~~~~~~~~~~~

t ! 1 1 ! ! 7

Fig. 12. Example of an expression containing a structure.

The only limitation on the Algol 68 tools is the non-recognition of certain deprecated features. GOT0 statements and clauses using round brackets as a short form notation for BEGIN . . . END, IF . . . FI and CASE . . . ESAC are treated just as any other sequential item, like a simple assignment. In contrast the N-S tool for Fortran 77 is rather more primitive than the Algol 68 system. It was developed primarily for use in a Software Engineering course for undergraduate Engineering students. It produces a separate chart for each Fortran module (i.e. main program, SUBROUTINE or FUNCTION) and within each module only takes into account DO loops and block IF statements. However, VAX/VMS extensions to the Fortran 77 DO loop are handled sensibly. The extensions are the DO WHILE statement, the END DO statement and the DO without a terminating label. The following statements are treated merely as sequential items and generate no special chart form: -arithmetic IF, and logical IF, - GOTO, computed GOT0 and assigned GOTO. It has to be noted that although it is possible, indeed sometimes necessary, to construct loops and choice clauses using logical IF and GOT0 statements these do not result in loop or choice clause charts when presented to the N-S tool. 3.

USING

N-S

CHARTS

AND

SUPPORT

TOOLS

N-S charts are a simple, easy-to-learn technique that can be employed at a number of stages in the software development cycle. When teaching program design, N-S charts are useful because the pictorial nesting of process boxes models top-down development in a very natural fashion. One can start with a rectangular box containing a description of an entire problem and then dissect it into a number of smaller boxes when breaking the task into subtasks. As the subtasks are further decomposed the process boxes may be subdivided yet again. Furthermore, by naming a process box of some subtask and, in effect, zooming in on it to develop its own decomposition, one has a convincing explanation of modular programming. At the early stages when sketching out a program design the notation of the charts provides a diagrammatic representation of control flow independent of any particular programming language. Since the notation has no direct mechanism for representing structures other than sequence, selection, repetition and block, structured programs will normally result for any target language. The contents of the boxes can initially be written in natural language and gradually be refined towards statements in a particular programming language. In Fig. 13, a typical example from the introductory programming course is given. It is the first stage in the development of a program to count the frequency of occurrence of letters of the alphabet in some data terminated by an asterisk. Despite the widely accepted belief that testing every statement and every decision outcome at least once is a useful minimum testing requirement it is still not always adhered to, even in industrial

Software engineering education

277

!_______________________________________~~~~~~~~~~~~~~~~_~~__~~__~~~_~

!

!

! Declare

count

array

of 26

elements

I !______________________________-________~~~~-~~~~~~~~~~~~~~~~~~~~____~ I ! Initialise count array to zero I !____________________________________________________________________! I ! WHILE read next character and It IS not a "*" ! DO t I

!_______________________________________~~~~~~~~~~~~~~~~~~~~~~~ ,

I

I

I

, t ! I

I ? 9 !_______________________________________________! I TRUE

1 9 1

!

character

to count

for

this

letter

I

!_________! FALSE

1 I ! ! !____________________________________________________~~~~~~~~~~~~~~~~~ ! ! Print the count array ! !________________________________________________________~~~~~~~~~-~~~ one

1 1

1 ! 1

is a letter

1 ! !_______________________________________~~~~~~~~~~~~~~~~~~~~~~~ I I Add

! I !

! I

IF

!

0 t

! 1

I I ! I !

Fig. 13. ExamF!a of preliminary program design using N-S charts.

settings[l 11. Certainly in the absence of tools it is a standard which is difficult to enforce. Algol 68 has, in general, fewer tools available to support its use, so the simple dynamic tool described previously, which is easy to use and interpret has had the welcome effect of encouraging more thorough testing of programs by students. At decision points within each two-way or multi-way selection structure a process box is generated for every decision outcome, even if there are no program statements to be placed within it. Therefore complete box coverage corresponds very nearly to complete branch testing and is certainly more thorough than complete statement testing. For example, the Algol 68 conditional statement with no ELSE part: IF condition THEN process FI generates an empty ELSE process box and if test data were supplied such that “condition” was only ever TRUE, although the statement would have been executed entirely, the blank ELSE box would have a zero execution count. Hence in order to achieve 100% box coverage, data which makes the “condition” FALSE would have to be selected, therefore executing an additional program branch but no additional program statements necessarily. The reason complete box coverage does not correspond exactly to complete branch coverage, even for Algol 68 programs free of GOT0 statements, is the ability to write in Algol 68 what is in effect a loop with two exit decision criteria. The construction: FOR identifier FROM bottom TO top WHILE condition DO process OD may have all its boxes covered without necessarily executing both exit branches, i.e. reaching the “top” limit on the loop control identifier and achieving “condition” equal to FALSE. Like conventional flowcharts, N-S charts are suitable as part of the documentation for a program. However, rather than supplying conventional flowcharts which are tedious to produce and likely to stay unrevised after program changes, students can automatically produce N-S charts and update them whenever the source program is changed.

278

M. R.

WDDDWARD

An additional and originally unforeseen use has been that the tools themselves have proved to be a fertile source of student projects and exercises. Developing and modifying the tools for a variety of languages has provided a number of worthwhile projects. A related project concerned with software metrics made use of the internal binary tree representation of simple programs to produce algebraic formulae for the number of paths[l2]. Indeed such thoughts originally motivated the use of + and * as characters to represent alternation and repetition respectively in the binary tree. Amongst the exercises set utilizing the tools, has been one to test the tools themselves. 4. DISCUSSION The importance of teaching general problem solving skills in introductory computing courses, using the method of top-down development in conjunction with structured programming has been well argued elsewhere[l3]. N-S charts provide compact two dimensional representations of algorithms which easily support these significant design concepts. No figures are available to quantify the benefits of using N-S charts as a teaching aid. The fact that students readily learn to use them for program design with positive effect would seem sufficient benefit by itself. The additional reinforcement provided by having N-S chart tools to assist testing and documentation is a bonus. Others have developed systems which automatically provide N-S charts of source language programs. Roy and St-Denis[l4] reported a system for Pascal which, although similar to the static tool for Algol 68 reported here, failed to produce the correct N-S chart for the CASE statement. In the COLUMBUS system[l5] special language independent formatting statements are inserted into the program source code, which is then preprocessed to produce an N-S chart and a program in the target language. Clark and Robinson[l6] have developed a dynamic execution monitoring system for Pascal based on N-S charts, which marks the current point of control as the program executes. The dynamic system reported here in section 3 differs from that of Clark and Robinson by being based on instrumentation with a postprocessor to produce the display and also the charts have a less fragmented appearance since consecutive simple statements are not separated by horizontal lines. Pong and Ng[17] have developed a program construction and editing tool that uses N-S charts as a graphical language on the screen. Their PIGS system for a subset of Pascal also has an interpreter built into it enabling run-time monitoring to be performed and for example data flow anomalies can be detected. Another related program construction tool for a subset of Pascal is the PECAN system of Reiss [ 181which permits multiple views of a program including an N-S chart view. A graphical editor using this view is being added to the PECAN system. Besides extending the ideas presented in this paper to other languages, work is in progress to construct a system which enables a user to develop an N-S chart representation of an algorithm, to edit it graphically and to execute and debug it graphically. Thus, all the way through the program development process, the user will work with the N-S chart representation and may finally choose to convert it to a “normal” program for production runs. The chart of course remains as part of the program documentation. It seems that N-S charts are sufficiently flexible that a complete programming environment based upon them becomes an attractive proposition. Acknowledgements-A number of students have assisted by implementing prototype versions of the tools mentioned here, or by participating in related projects. In particular acknowledgements are due to B. Brannigan, B. K. Chew, M. R. Girgis, J. Harris. K. K. Lai and M. R. Merrick. REFERENCES 1. Nassi I. and Shneiderman B., Flowchart techniques for structured programming. ACM Sigpkm Nor. 8 (No. 8), 12-26 (1973). 2. Yoda C. M. and Schrag M. L., Nassi-Shneidennan charts-an alternative to flowcharts for design. Proceedings of the &-&ware Quality Assurance Workshop: Functional and Performance Issues, San Diego. Published in ACM Software Engineering Notes (November 1978). 3. Miihlbacher J. R., A tutorial introduction to structured microprocessor software development. J. Microcomput. Appl. 5 (No. l), 67-86 (1982). 4. Walsh B. C., Proper Basic. Wiley, Chichester (1983). 5. Merchant M. J., FORTRAN 77-Lunguage and Sryle. Wadsworth, Belmont, California (1981). 6. Parkin A., COBOL for Budents, 2nd edn. Edward Arnold, London (1982). 7. Chapin N., New format for flowcharts. Software-Pratt. Exper. 4 (No. 4), 341-357 (1974).

Software engineering education

279

8. Lindsey C. H., Structure charts: a structured alternative to flowcharts. ACM Sigplan Nor. 12 (No. 1I), 36-49 (1977). 9. Probert R. L., Optimal insertion of software probes in well-delimited programs. IEEE Trans. Software Engng SE8 (No. I), 34-42 (1982). 10. Woodward P. M. and Bond S. G., Guide to ALGOL 68for Users of RS Systems. Edward Arnold, London (1983). 11. Petschenik N. H., Practical priorities in system testing. IEEE So&ware 2 (No. 5), 18-23 (1985). 12. McCabe T. J., A complexity measure. IEEE Trans. Software Engng SE-2, (No. 4), 308-320 (1976). 13. Woodhouse D., Introductory courses in computing: aims and languages. Comput Educ. 7 (No. 2) 78-89 (1983). 14. Roy P. and St-Denis R., Linear flowchart generator for a structured language. ACM Sigplan Nor. 11 (No. 1I), 58-64 (1976). 15. Witt J., The COLUMBUS approach. IEEE Trans. Sofware Engng SE-1 (No. 4), 358-363 (1975). 16. Clark B. E. J. and Robinson S. K. A graphically interacting program monitor. Compur. J. 26 (No. 3), 235238 (1983). 17. Pong M. C. and Ng N., PIGS-a system for programming with interactive graphical support. Sofrware-Pratt. Exper. 13 (No. 9). 847-855 (1983). 18. Reiss S. P., PECAN: program development systems that support multiple views. IEEE Trans. Soffware Engng SE-11 (No. 3) 276285 (1985).

C.&E. ll,CO