© 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

24
© 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Lecture 7a Modelling Logic Requirements (Textbook Chapter 8)

Transcript of © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

Page 1: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 1

Lecture 7a

Modelling Logic Requirements

(Textbook Chapter 8)

Page 2: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 2

Learning Objectives

Use Structured English as a tool for representing steps in logical processes in data flow diagrams.

Use decision tables to represent the logic of choice in conditional statements.

Select among Structured English and decision tables for representing processing logic.

Page 3: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 3

Logic Modelling

Data flow diagrams do not show the logic inside the processes or the contents of data flows.

Logic modelling involves representing internal structure and functionality of processes depicted on a DFD.

Logic modelling can also be used to show when processes on a DFD occur.

Data modelling is used to represent the contents and structure of the DFD data flows & data stores. Data Modelling is covered in 2002ICT.

Page 4: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 4

Modelling a System’s Logic

Page 5: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 5

Deliverables and Outcomes

Structured English representation of process logic.

Decision Tables representation. Sequence diagram (mainly OO approach). Activity diagram (mainly OO approach).

Page 6: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 6

Modelling Logic with Structured English

Structured English: modified form of English language used to specify the logic of information system processes.

No single standard. Typically relies on action verbs and noun

phrases and contains no adjectives or No specific standards.

Page 7: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 7

Recall the DFDs previously presented...

The Hoosier Burger Example

Page 8: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 8

… and the resulting Level-0 Diagram

Page 9: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 9

Modelling Logic with Structured English

The Hoosier Burger Inventory Control System

Page 10: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 10

Modelling Logic with Structured English (cont.)

Page 11: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 11

Modelling Logic with Structured English (cont.)

Page 12: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 12

Repetition can also be modelled using DO-WHILE:

Modelling Logic with Structured English

READ Inventory recordsWHILE NOT End-of-File DO

BEGIN IFIF Quantity-in-Stock is less Minimum-order-

quantityTHEN GENERATE new orderELSE DO nothing // optional

END IFEND DO

What is the difference to DO-UNTIL ??

Page 13: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 13

Cascading IF-THEN tests or a case statement can be combined to cover other possibilities. E.g. imagine modelling an emergency reorder:

Modelling Logic with Structured English

READ Quantity-in-StockSELECT CASE

CASE 1 (Quantity-in-Stock greater then Minimum-order-quantity)DO nothing

CASE 2 (Quantity-in-Stock equals Minimum-order-quantity)DO nothing

CASE 3 (Quantity-in-Stock is less than Minimum-order-quantity)GENERATE new order

CASE 4 (Stock Out)INITIATE emergency reorder routine

END CASE

Page 14: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 14

Modelling Logic with Decision Tables

Research (Yourdon, 1989) has shown people become confused when trying to interpret more than three nested IF-THENs.

Thus, diagrams are more appropriate for complicated decision logic.

A Decision table is a matrix representation of the logic of a decision which specifies the possible conditions for the decision and the resulting actions.

Page 15: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 15

Modelling Logic with Decision Tables (cont.)

Page 16: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 16

Modelling Logic with Decision Tables (cont.)

Condition stubs: that part of a decision table that lists the conditions relevant to the decision.

Action stubs: that part of a decision table that lists the actions that result for a given set of conditions.

Page 17: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 17

Modelling Logic with Decision Tables (cont.)

Rules: that part of a decision table that specifies which actions are to be followed for a given set of condition.

Indifferent condition: in a decision table, a condition whose value does not affect which actions are taken for two or more rules.

Page 18: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 18

Modelling Logic with Decision Tables (cont.)

Procedure for Creating Decision TablesName the condition and the values that each

condition can assume.Name all possible actions that can occur.List all possible rules.Define the actions for each rule.Simplify the table.

Page 19: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 19

Modelling Logic with Decision Tables (cont.)

“IF”

“THEN”

“IF-THEN”

Page 20: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 20

Modelling Logic with Decision Tables (cont.)

Simplified Decision Table – Staff is paid base salary, regardless

Page 21: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 21

Modelling Logic with Decision Tables

Hoosier Burger complete Decision Table

Page 22: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 22

Modelling Logic with Decision Tables (cont.)

Hoosier Burger simplified Decision Table

Page 23: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 23

Structured English or Decision Tables?

Criteria Structured English

Decision Tables

Determining Conditions and Actions

Ok Average

Transforming Conditions and Actions into Sequence

Best Average

Checking Consistency and Completeness

Average Best

Page 24: © 2008 Prentice Hall, Ovidiu Noran Lecture 7a 1 Modelling Logic Requirements (Textbook Chapter 8)

© 2008 Prentice Hall, Ovidiu NoranLecture 7a 24

Summary

In this chapter you learned how to:Use Structured English as a tool for

representing steps in logical processes in data flow diagrams.

Use decision tables to represent the logic of choice in conditional statements.

Select Structured English or decision tables for representing processing logic.