Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 7: Software Design (Part II) Dr Valentina Plekhanova University of Sunderland, UK

Similar presentations


Presentation on theme: "Lecture 7: Software Design (Part II) Dr Valentina Plekhanova University of Sunderland, UK"— Presentation transcript:

1 Lecture 7: Software Design (Part II) Dr Valentina Plekhanova University of Sunderland, UK http://www.cet.sunderland.ac.uk/~cs0vpl/SE-Com185.htm

2 Lecture 7Valentina Plekhanova 2 Low-level Design Also known as procedural or functional 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.

3 Lecture 7Valentina Plekhanova 3 Low-level Design If our designs are good, each procedure or function will only be required to carry out a fairly small and specific subtask. 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. 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. Once that is done, it should be fairly easy to translate each low-level design into program code.

4 Lecture 7Valentina Plekhanova 4 Low-level Design The actual choice of design representation to use is not important, designers have their own favourite methods. 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. 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. What all low-level design representation methods do is to portray in a way that is not specific to any one programming language.

5 Lecture 7Valentina Plekhanova 5 Low-level Design define input data; define input data; assign data to a variable; assign data to a variable; define output data from the module; define output data from the module; define another (sub-) modules that can be 'called up' from this module. define another (sub-) modules that can be 'called up' from this module.

6 Lecture 7Valentina Plekhanova 6 Low-level Design 4 main methods: 4 main methods:  pseudo code  flow charts  JSP  Nassi-Shneiderman diagrams

7 Lecture 7Valentina Plekhanova 7 Low-level Design: Basic Constructs All these 4 main methods of producing low-level design documents are based on 3 basic constructs: All these 4 main methods of producing low-level design documents are based on 3 basic constructs:  sequence;  selection;  iteration (repetition).

8 Lecture 7Valentina Plekhanova 8 Low-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.

9 Lecture 7Valentina Plekhanova 9 Low Level Design Although these constructs are sufficient, it is often useful to include three more constructs: 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.

10 Lecture 7Valentina Plekhanova 10 Basic Sections There are usually 3 sections to all Low- level designs: initialisation, processing, and termination. There are usually 3 sections to all Low- level designs: initialisation, processing, and termination.

11 Lecture 7Valentina Plekhanova 11 Low Level Design: Initialisation Initialisation Initialisation section includes opening files, reading the first record, and, if necessary, printing page and report headings.

12 Lecture 7Valentina Plekhanova 12 Low Level Design: Processing Processing DO 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

13 Lecture 7Valentina Plekhanova 13 Low Level Design: Processing  DO until end-of-file  Processing steps  Read next record  END DO

14 Lecture 7Valentina Plekhanova 14 Low Level Design: Termination Termination Termination section includes what happens at the very end of the program, such as closing the files and stopping the program.

15 Lecture 7Valentina Plekhanova 15 What is Pseudocode? 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. Instead, or in combination, we can use program flowcharts.

16 Lecture 7Valentina Plekhanova 16 Pseudocode: Important Notes Each textbook and each individual designer may have their own personal style of pseudocode. 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. 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. There is no universal "standard" for the industry, but for instructional purposes it is helpful if we all follow a similar style.

17 Lecture 7Valentina Plekhanova 17 Examples of Pseudocode: Example 1 - Examples of Pseudocode: Example 1 - The problem is to find the roots of a quadratic equation.  Step 1  Step 1 Prompt for and read the coefficients a, b, and c  Step 2  Step 2 If a = 0, do steps 3,4  Step 3  Step 3 If b = 0 also, Error message: "no roots" and exit  Step 4  Step 4 Write single root -c/b and exit  Step 5  Step 5 Set d = b^2 - 4*a*c and if d < 0 Error message: "not real" and exit  Step 6  Step 6 Set s = -(b + sqrt(d)*sign(b))/2  Step 7  Step 7 Set x1 = s/a. Write this first (robust) root  Step 8  Step 8 Set x2 = c/s. Write this second (robust) root.  Step 9  Step 9 Set x3 = -(b - sqrt(d)*sign(b))/(2*a).  Write this second (risky) root.

18 Lecture 7Valentina Plekhanova 18 Example 2: Pseudocode prompt the user to input the number of days; prompt the user to input the number of days; user inputs the number of days; user inputs the number of days; multiply the number of days by 7 hours; multiply the number of days by 7 hours; display the total hours with an output prompt. display the total hours with an output prompt.

19 Lecture 7Valentina Plekhanova 19 Low-level Design: Flow charts A flowchart is a pictorial representation of the logic in a computer program A flowchart is a pictorial representation of the logic in a computer program Based on the 3 basic constructs, sequence, selection and iteration. 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. In flow chart, certain shapes have special meaning, and arrows are used to connect pieces of the flowchart.

20 Lecture 7Valentina Plekhanova 20 Low-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.

21 Lecture 7Valentina Plekhanova 21 Some Examples: Pseudocodes & Flow Charts Pseudocodes & Flow Charts

22 Lecture 7Valentina Plekhanova 22 Flow 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.

23 Lecture 7Valentina Plekhanova 23 Flow chart – Selection: IF-THEN-ELSE Flow chart – Selection: IF-THEN-ELSE IFTHENELSE ENDIF 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 THEN  IF condition THEN  sequence 1  ELSE  sequence 2  END IF ELSE The ELSE keyword and "sequence 2" are optional. If the condition is true, sequence 1 is performed, otherwise sequence 2 is performed.

24 Lecture 7Valentina Plekhanova 24 Flow chart – Selection: IF-THEN-ELSE Example  IFTHEN  IF hours > 35 THEN  Display overtime message  ELSE  Display regular time message  END IF

25 Lecture 7Valentina Plekhanova 25 Flow chart - Iteration (e.g. for, while) This loop is a specialised construct in which an index variable is automatically initialised, incremented and tested. FOREND FOR Two keywords, FOR and END FOR are used. Example: Example: The general form is: FOR  FOR index = start to finish  sequence END FOR  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.

26 Lecture 7Valentina Plekhanova 26 Flow chart - Iteration: WHILE WHILE The WHILE construct is used to specify a loop with a test at the top. WHILE END WHILE The beginning and ending of the loop are indicated by two keywords WHILE and END WHILE. The general form is: WHILE  WHILE condition  sequence END WHILE  END WHILE Example: Example:  WHILE  WHILE number of days < 6  Compute hours as number of days * hours  END WHILE

27 Lecture 7Valentina Plekhanova 27 Flow chart - Iteration: WHILE The loop is entered only if the condition is true. sequence 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.

28 Lecture 7Valentina Plekhanova 28 Low-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).

29 Lecture 7Valentina Plekhanova 29 Week 8: 24.04.2003-28.04.2003 Project Control Session Tutorial Time: 10 minutes for each Team Tutorial Time: 10 minutes for each Team Scheduledocumentation 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.


Download ppt "Lecture 7: Software Design (Part II) Dr Valentina Plekhanova University of Sunderland, UK"

Similar presentations


Ads by Google