IMSE Lecture Week 6 Low Level Design - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

IMSE Lecture Week 6 Low Level Design

Description:

Flow charts. traditional method, now out of favour. the reason is because flow charts do not enforce good design practices, as they ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 19
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 ...
  • BEGIN FUNCTION
  • if sex male
  • then
  • display Mr.
  • else
  • display Ms.
  • display name
  • END FUNCTION

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
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

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

  • BEGIN

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

10
Flow chart - selection
  • e.g.
  • condition
  • T F BEGIN
  • if k gt max
  • print k gt max
  • then else else
  • part part print k lt max
  • END
  • 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

11
Flow chart - iteration (e.g. for, while)
  • e.g.
  • BEGIN
  • deduct 1 while k gt min
  • from k print k
  • loop k k-1
  • tasks end while
  • print k END


  • k gt T
    loop and endloop
  • min loop condition may also
    be used
  • F

12
Flow chart - iteration (e.g. do while, or repeat
until)
  • e.g.
  • BEGIN
  • do
  • loop tasks print k
  • k k-1
  • while k gt min
  • END
  • kgtmin
  • loop T loop and
    endloop
  • condition F
    again may be seen

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

  • else if k gt 0
  • k gt T print k gt 0
    print k gt 0
  • 0
    END
  • F

14
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

15
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
  • BEGIN
  • initialisations
  • loop
  • input mark
  • if mark gt max
  • set max to mark
  • until mark 999
  • display max
  • END

16
Step 2
  • BEGIN
  • set max to 0
  • loop
  • input mark
  • if mark gt max
  • set max to mark
  • until mark 999
  • display max
  • END
  • 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

17
Step 3
  • BEGIN
  • input 1st mark
  • set max to 1st mark
  • loop
  • if mark gt max
  • set max to mark
  • input next mark
  • until mark 999
  • display max
  • END
  • 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

18
Final Level of Refinement
  • BEGIN
  • input 1st mark
  • set max to 1st mark
  • loop until mark 999
  • if mark gt max
  • set max to mark
  • input next mark
  • endloop
  • if max not equal to 999
  • display max
  • END
  • 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