We begin the discussion of JSD with an example of bad system development followed by system development using JSD.
The owner wishes to produce management information in the form of a daily report at the end of the day's business and invites a developper to produce the information. The report has just two lines:
Number of sessions = nnnn
Average session time = mm
The developper immediately ascertains that the report can be produced by a single function that consists of two parts. The first component processes the day's data and the second component prints the report. Moreover, the processing component consists of first counting the total number of sessions, and dividing this by the total time of all sessions. Counting the sessions is easy enough--simply count the number of messages with an 'S' code. Computing the total time isn't much harder:
totaltime = (endtime of session 1 - starttime of session 1) + (endtime of session 2 - starttime of session 2) +
....... (endtime of session n - starttime of session n)
or more conveniently,
totaltime = (endtime of session 1 + endtime of session 2 + ... + endtime
of session n) -
(starttime of session 1 + starttime of session 2 + ... + starttime of session
n)
The resulting solution, functionally designed and implemented in structured code, is:
begin open message stream;
get message
number := 0; totaltime := 0;
dowhile <not end-of-stream>
if code = 'S'
then
number := number + 1;
totaltime := totaltime - starttime
else totaltime :=
totaltime - endtime
endif
get message
endwhile
print 'NUMBER OF SESSIONS = ', number;
if number <> 0
then print 'AVERAGE SESSION TIME = ', totaltime
/ number;
endif
close message stream;
end
The system goes into production and everyone is happy. Soon, however, the owner approaches the developper with a small enhancement to the report. The enhancement consists of just one additonal line to the report:
LONGEST SESSION TIME = ppp
Careful examination convinces the developper that the enhancement cannot be made except by throwing away the existing code and starting anew. The reader should be persauded that indeed this is the case. The developper convinces the owner that there are technical reasons why the modification cannot be made, and the owner, dazzled by the developper's brilliance, agrees that the change isn't crucial anyway.
However, the owner returns a little later with another request, to produce two reports instead of one, with the same format as the original report. The first report should deal with sessions starting before noon, while the second would summarize those starting during the afternoon. Because the change is so small, the owner is convinced that the developper will be able to satisy the request without difficulty. Again, the developper (and, I hope, the reader), realizing that the system could not be modified, gives the owner an explanation, something to do with the capacity of the hard disk. The owner is less dazzled and definitely disatisfied with the service being given.
Soon, the owner returns with a critical request: the telecommunications line has been dropping some of the 'S' and 'E' messages, and sessions involving these dropped messages must not be included in the report. Once again the developper realizes that the change cannot be made without totally scrapping the existing system. The developper's attempts at explanation fall upon deaf ears. Neither the time nor the budget is available to create a new system, and the developper is soon walking the streets in search of a new job.
The structure text for the system should have been the following:
The three system changes asked for by the manager of the paddle-boat system aren't hard to make. They are given below:
(i) Add a line, LONGEST SESSION TIME = ppp, to original report
A modified or new text line is indicated by an arrow in front of the line.
A modified or new text line is indicated by an arrow in front of the line.