IMSE Week 7 NassiShneiderman Diagrams - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

IMSE Week 7 NassiShneiderman Diagrams

Description:

After 6pm on Fridays you go to the Manor Quay. ... go to the Manor Quay work late. T if driving F go home. drink Coke drink Beamish make dinner ... – PowerPoint PPT presentation

Number of Views:122
Avg rating:3.0/5.0
Slides: 14
Provided by: LindaS126
Category:

less

Transcript and Presenter's Notes

Title: IMSE Week 7 NassiShneiderman Diagrams


1
IMSE Week 7Nassi-Shneiderman Diagrams
  • developed by I. Nassi and B. Shneiderman in 1973,
    and extended by N. Chapin in 1974
  • they graphically represent the tasks and control
    flow within a function, in terms of sequence,
    selection and iteration
  • begin with a large rectangle representing the
    function to be designed
  • then the inside of the rectangle is partitioned
    to represent the internal processing (the tasks
    and control flow)
  • Nassi-Shneiderman diagrams aid well structured
    design with good control flow - its impossible
    to draw NSDs for badly designed functions

2
Nassi-Shneiderman - Sequence
  • 3
    tasks, performed
  • Do this
    sequentially, e.g.
  • then this
    print hello
  • a
    10
  • then finally this b 20

3
Nassi-Shneiderman - Selection
  • if then else
  • if k gt max
  • print k gt max
  • else
  • print k lt max
  • T condition F
  • do this do this
  • Case (e.g. a menu)
  • case condition
  • value 1 value 2 value 3
  • do this do this do this

4
Nassi-Shneiderman - Iteration
  • while (or for)
  • while (k gt min)
  • print k
  • k k-1
  • while true
  • do this
  • then this
  • do while (or repeat until)
  • do
  • print k
  • k k-1
  • while k gt min
  • do this
  • then this
  • while true

5
Nassi-Shneiderman abstract example
  • do this
  • then this
  • then this
  • while true
  • T if this is
    true F
  • do this
  • while true do
    this
  • finally do this

6
End of a working day
  • Produce a Nassi-Shneiderman diagram
    corresponding to a single function which performs
    the following tasks
  • Suppose its the end of a working day.
  • After 6pm on Fridays you go to the Manor Quay.
  • If youre driving you drink Coke, if not you
    drink Beamish. At 11.30 you go home and go to
    bed.
  • If its not a Friday you work late before going
    home and making dinner. After dinner you watch TV
    and then go to bed.

7
End of a working day
  • End of a Working
    Day
  • calculate time and day of week
  • T if Friday and after 6.00pm
    F
  • go to the Manor Quay
    work late
  • T if driving F
    go home
  • drink Coke drink Beamish make
    dinner
  • until its 11.30 pm
  • go home
    watch TV
  • go to bed

8
Back to the student marks program
  • First Cut
  • Structure Chart Student

  • Marks
  • Valid
    Stored
  • Marks
    Ranges
  • Accept Calculate
    Generate
  • Valid Marks Marks Range
    Graph
  • We now produce one low level diagram or PDL
    procedure for each of these 4 modules

9
NSDs for student marks program
  • Remember that the program accepts pre-validated
    student marks and produces a graph showing the
    count for each of the ranges 0-10, 11-20,
    21-30, ..., 81-90, 91-100.
  • Stated assumptions the marks are input as whole
    numbers, and the graph is to be a bar chart of
    asterisks.
  • Student Marks
  • set up data
  • call accept valid marks (out valid marks)
  • call calculate marks range (in valid marks, out
    stored ranges)
  • call generate graph (in stored ranges)

10
NSD for Accept Valid Marks
  • Accept Valid Marks (out valid marks)
  • set up data
  • display How many marks?
  • accept the number of marks
  • for each mark
  • accept mark
  • display the entered mark
  • store mark
  • return the marks

11
NSD for Calculate Marks Range
  • Calculate Marks Range (in valid marks, out
    stored ranges)
  • set up data
  • for each mark
  • subtract 1 from mark
  • divide mark by 10 and ignore decimal
    part
  • to find the correct range array
    element
  • increment the range array element
  • return the ranges

12
NSD for Generate Graph
  • Generate Graph (in stored ranges)
  • set up data
  • clear the screen
  • display graph title
  • for each range
  • calculate lower and upper boundaries
  • T if lower boundary 1
    F
  • set lower boundary to 0
  • display range boundaries
  • for each star
  • display

13
Notes on PDL
  • See Sommerville p126 - 129
  • In principle, PDLs may be based on any
    programming language. Ada, a standard high level
    language in the defence industry, was designed
    for readability. It is therefore a good choice as
    a base language for a PDL.
  • PDLs, with elements of computer code and
    structured natural language, are a compromise
    between comprehensibility and precision.
Write a Comment
User Comments (0)
About PowerShow.com