Title: Lecture 7: Software Design (Part II)
1Lecture 7 Software Design (Part II)
- Dr Valentina Plekhanova
- University of Sunderland, UK
http//www.cet.sunderland.ac.uk/cs0vpl/SE-Com185.
htm
2Low-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.
3Low-level Design
- If our designs are good, each procedure or
function will only be required to carry out a
fairly small and specific subtask. - We now need to consider the design of the code
that will carry out each of the identified
subtasks. - Once that is done, it should be fairly easy to
translate each low-level design into program code.
4Low-level Design
- The actual choice of design representation to use
is not important, designers have their own
favourite methods. - It is a matter of individual choice (unless you
work for an organisation that imposes a
particular design representation) as to the
method of design representation you use to design
low-level code. - What all low-level design representation methods
do is to portray in a way that is not specific to
any one programming language.
5Low-level Design
- define input data
- assign data to a variable
- define output data from the module
- define another (sub-) modules that can be 'called
up' from this module.
6Low-level Design
- 4 main methods
- pseudo code
- flow charts
- JSP
- Nassi-Shneiderman diagrams
7Low-level DesignBasic Constructs
- All these 4 main methods of producing low-level
design documents are based on 3 basic constructs - sequence
- selection
- iteration (repetition) .
8Low-level Design
- Sequence is a linear progression where one task
is performed sequentially after another. - Iteration WHILE is a loop with a simple
conditional test at its beginning. - Selection IF-THEN-ELSE is a decision in which a
choice is made between two alternative courses of
action.
9Low Level Design
- Although these constructs are sufficient, it is
often useful to include three more constructs - REPEAT-UNTIL is a loop with a simple conditional
test at the bottom. - FOR is a special loop in which an index variable
is automatically initialised, incremented, and
tested. - CASE is a multiway branch (decision) based on the
value of an expression. CASE is a generalisation
of IF-THEN-ELSE.
10Basic Sections
- There are usually 3 sections to all Low-level
designs initialisation, processing, and
termination.
11Low Level Design Initialisation
- Initialisation section includes opening files,
reading the first record, and, if necessary,
printing page and report headings.
12Low Level Design Processing
- Processing section includes DO statements to show
repetitive tasks that are performed on each
record in the file there are two ways to show
this loop - DO while data remains
- Processing steps
- Read next record
- END DO
13Low Level Design Processing
- DO until end-of-file
- Processing steps
- Read next record
- END DO
14Low Level Design Termination
- Termination section includes what happens at the
very end of the program, such as closing the
files and stopping the program.
15What is Pseudocode?
- Pseudocode is simply a way of describing the
steps to the solution of a programming task,
using a few English words in a structured way,
though not in any particular programming
language. - Instead, or in combination, we can use program
flowcharts.
16Pseudocode Important Notes
- Each textbook and each individual designer may
have their own personal style of pseudocode. - Pseudocode is not a rigorous notation, since it
is read by other people, not by the computer. - There is no universal "standard" for the
industry, but for instructional purposes it is
helpful if we all follow a similar style.
17Examples of Pseudocode Example 1 - The problem
is to find the roots of a quadratic equation.
- Step 1 Prompt for and read the coefficients a,
b, and c - Step 2 If a 0, do steps 3,4
- Step 3 If b 0 also, Error message "no roots"
and exit - Step 4 Write single root -c/b and exit
- Step 5 Set d b2 - 4ac and if d lt 0 Error
message "not real" and exit - Step 6 Set s -(b sqrt(d)sign(b))/2
- Step 7 Set x1 s/a. Write this first (robust)
root - Step 8 Set x2 c/s. Write this second
(robust) root. - Step 9 Set x3 -(b - sqrt(d)sign(b))/(2a).
- Write this second (risky) root.
18Example 2 Pseudocode
- prompt the user to input the number of days
- user inputs the number of days
- multiply the number of days by 7 hours
- display the total hours with an output prompt.
19Low-level Design Flow charts
- A flowchart is a pictorial representation of the
logic in a computer program - Based on the 3 basic constructs, sequence,
selection and iteration. - In flow chart, certain shapes have special
meaning, and arrows are used to connect pieces of
the flowchart.
20Low-level Design Flow charts
- Used to indicate the beginning (start) or end
(stop) of a computer program or subroutine. - Used to indicate some type of input or output,
such as opening or closing Files. - Also known as a decision symbol, this is used to
indicate a decision to be made, choices based on
logic an if statement - Arrows are used to show the flow of the program
to show where the next item is located.
21Some Examples
22Flow chart Sequence
- Sequential control is indicated by writing one
action/task after another, each action/task on a
line by itself, and all actions/tasks aligned
with the same indent. - The actions/tasks are performed in the sequence
(top to bottom) that they are written.
23Flow chart Selection IF-THEN-ELSE
- Binary choice on a given Boolean condition is
indicated by the use of four keywords IF, THEN,
ELSE, and ENDIF. - The general form is
- IF condition THEN
- sequence 1
- ELSE
- sequence 2
- END IF
- The ELSE keyword and "sequence 2" are optional.
If the condition is true, sequence 1 is
performed, otherwise sequence 2 is performed.
24Flow chart Selection IF-THEN-ELSE Example
- IF hours gt 35 THEN
- Display overtime message
- ELSE
- Display regular time message
- END IF
25Flow chart - Iteration (e.g. for, while)
- This loop is a specialised construct in which an
index variable is automatically initialised,
incremented and tested. - Two keywords, FOR and END FOR are used.
- Example The general form is
- FOR index start to finish
- sequence
- END FOR
- At the initiation of the loop, the index variable
is set to the starting value. - At the end of each iteration, the index variable
is automatically incremented. - The loop repeats until the index value reaches
the finish value.
26Flow chart - Iteration WHILE
- The WHILE construct is used to specify a loop
with a test at the top. - The beginning and ending of the loop are
indicated by two keywords WHILE and END WHILE. - The general form is
- WHILE condition
- sequence
- END WHILE
- Example
- WHILE number of days lt 6
- Compute hours as number of days hours
- END WHILE
27Flow chart - Iteration WHILE
- The loop is entered only if the condition is
true. - The "sequence" is performed for each iteration.
- At the conclusion of each iteration, the
condition is evaluated and the loop continues as
long as the condition is true.
28Low-level Design Important Notes
- Time spent on the design stage of the development
cycle will lead to less time spent on testing,
debugging and re-writing your programs to make
them work properly. - Lecture Notes are based on materials taken from
Books Pfleeger Sommerville Vliet (see
References Site).
29Week 8 24.04.2003-28.04.2003Project Control
Session
- Tutorial Time 10 minutes for each Team
- Students will present project file, particularly
Schedule, plus any project documentation. - Students will describe where they are in the
project and any problems encountered. - During the discussion reviewers will ask to see
evidence of deliverables for any tasks that are
complete to determine whether they have in fact
been done.