IMSE Lecture Week 6 - Low Level Design - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

IMSE Lecture Week 6 - Low Level Design

Description:

Michael Jackson. in the JSP method * repetition. Show logical order and ... diamond, and the then or else part may be directly below the diamond - wherever works best ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 20
Provided by: LindaS126
Category:

less

Transcript and Presenter's Notes

Title: IMSE Lecture Week 6 - Low Level Design


1
IMSE Lecture Week 6 - Low Level Design
  • Summary of last week
  • Transform Analysis - 4 steps
  • 1 annotate the DFD (without redrawing it)
  • 2 draw the intermediate diagram
  • 3 draw the first cut structure chart
  • 4 refine the structure chart
  • Weve covered the first 3 steps so far

2
Delaying Step 4
  • step 4 (refining the structure chart) must be
    delayed
  • first we need to think about low-level design
    issues
  • long diversion needed before we can produce a
    final refined structure chart for the system

3
High Level Design
  • high level design documents such as structure
    charts show
  • - the overall system design
  • - how the program is decomposed into separate
    modules
  • - which modules call which other ones
  • - how they communicate via data and flags
  • they do not show
  • - the order in which the modules are called
  • - the number of times they are called if its
    more than once
  • - the condition(s) determining
    optional/conditional invocation
  • - the internal workings of the modules

4
Low Level Design
  • Also known as procedural or functional design
  • - the design of the internal workings of a
    module
  • - the fine details of the system
  • - adds to the high level design
  • - details kept separate from the high level
    design, for clarity
  • 4 main methods
  • - pseudo code (most popular nowadays)
  • - JSP
  • - flow charts
  • - Nassi-Shneiderman diagrams

5
3 Basic Constructs
  • all these 4 main methods of producing low-level
    design documents are based on 3 basic constructs
  • - sequence
  • - selection
  • - iteration
  • all the internal logic of our modules can be
    expressed using only these 3 constructs

6
Pseudo code
  • Use of words rather than diagrams, good but not
    visual
  • More closely resembles the coded-up module
  • various terminology exists, e.g.FUNCTION,
    procedure, loop until, while we will use COM168
    version.
  • if sex male
  • write Mr.
  • else
  • write Ms.
  • ifend
  • write name

7
JSP
  • Original concepts
  • developed by Dijkstra,
  • but made popular by
  • Michael Jackson
  • in the JSP method
    repetition
  • Show logical order and
  • control of processing
    selection

  • o
    o

8

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
9
Flow charts
  • traditional method, now out of favour
  • the reason is because flow charts do not enforce
    good design practices, as they may produce
    modules with very poor flow of control, i.e.
    spaghetti code
  • again based on the 3 basic constructs, sequence,
    selection and iteration

10
Flow chart - sequence
  • 1st task add 10
    2 tasks, performed
  • to a
    sequentially, e.g.


  • a a 10
  • 2nd task deduct
    b b - 2
  • 2 from b

11
Flow chart - selection
  • e.g.
  • condition
  • T F
  • if k gt max
  • write k gt max
  • then else else
  • part part write k lt max
  • ifend
  • T and F may be right , left or below the
    diamond, and the then or else part may be
    directly below the diamond - wherever works best

12
Flow chart - iteration (e.g. for, while)
  • e.g.
  • deduct 1 loop while k gt min
  • from k write k
  • loop k k-1
  • tasks loopend
  • print k


  • k gt T
  • min loop condition
  • F

13
Flow chart - iteration (e.g. do while, or repeat
until)
  • e.g.
  • loop
  • loop tasks print k
  • k k-1
  • loopend when k lt min
  • kgtmin
  • loop T
  • condition
  • F

14
Flow chart - selection (e.g. else if, case)
  • k gt T print k gt 100 e.g.
  • 100
  • F
    if k gt 100
  • k gt T print k gt 50
    write k gt 100
  • 50
    elseif k gt 50
  • F write
    k gt 50

  • elseif k gt 0
  • k gt T print k gt 0
    write k gt 0
  • 0
    ifend
  • F

15
Pseudocode and Stepwise Refinement - Top Mark
Example
  • using pseudocode and stepwise refinement design
    the internal details of a single module whose
    role is to find the top mark from a set of marks
    terminated with 999
  • 2 general principles
  • design the algorithm in steps, and always walk
    through it with test data after each refinement
  • when designing algorithms with loops always take
    care with
  • pre-loop initialisation
  • always exiting from the loop
  • post-loop tidying up
  • NB there will almost always be more than one
    correct solution

16
Step 1
  • decompose into 3 parts - start up, process, end
  • always leave initialisations until after the main
    processing is clearer
  • after clarifying the main processing and walking
    through it with some test data we see that step 2
    needs to include the initialisation of max
  • initialisations
  • loop
  • read mark
  • if mark gt max
  • max lt- mark
  • endif
  • loopend when mark 999
  • write max

17
Step 2
  • max 0
  • loop
  • read mark
  • if mark gt max
  • max lt- mark
  • endif
  • loopend when mark999
  • write max
  • this looks good, but provides us with an
    unreliable algorithm
  • it would not always give the correct result -
    walk through the algorithm with all negative
    marks - the max mark would be incorrectly
    displayed as 0
  • a more reliable algorithm needs to be designed,
    to cater for unlikely possibilities which may one
    day happen

18
Step 3
  • read 1st mark
  • max 1st mark
  • loop
  • if mark gt max
  • max lt- mark
  • endif
  • read next mark
  • loopend when mark 999
  • write max
  • this looks better, but is still not perfect
  • walk through the algorithm with an empty set of
    marks
  • the max mark would be incorrectly set to 999
  • the loop would never exit (common error) as
    processing would stop at input next mark

19
Final Level of Refinement
  • read 1st mark
  • max 1st mark
  • loop while mark not equal to 999
  • if mark gt max
  • max lt- mark
  • endif
  • read next mark
  • loopend
  • if max not equal to 999
  • write max
  • endif
  • solution uses sequence, selection and repetition
  • common mistake in previous steps - listing some
    of the component parts in the wrong order
  • - the 1st mark was originally input inside the
    loop
  • - loop condition was tested at the end, not the
    start of the loop
  • walking through with test data at each step helps
    find correct ordering
  • final algorithm is now fully designed and ready
    to be coded up
Write a Comment
User Comments (0)
About PowerShow.com