Uploaded by Yazeed alwkyan

Decision Tables Trees chapter 5 summary

advertisement
Chapter 9
Describing process specifications and Structured Decisions
Processes in a DFD are not defined in detail. Therefore, it is almost impossible to
understand the meaning of the DFD precisely and accurately.
Process specification is done for primitive processes.
The goals of producing process specifications are:
-
Reduce process ambiguity
Obtain a precise description of what is accomplished.
Validate the system design, including data flow diagrams and the data
dictionary by making sure that all the inputs that are necessary to produce the
output are included and represented in the DFD and DD.
Process specifications are not created for:
o Physical input and/or output processes(read/write).
o Processes that represent simple data validation(simple editing).
o Processes for which prewritten code already exists(uses systems
subprograms).
Notations for Process specifications:
1. Structured English.
2. Decision Tables.
3. Decision Trees.
1. Structured English (pseudo code)
Structured English includes two kinds of sentences:
- Basic sentences
- Compound sentences
Basic Sentences like :
1. An algebraic equation. For example,
X = (y * z) / (q + 4)
2. A simple imperative sentence consisting of a verb and object. There is no
restriction on verbs and objects. For example,
Calculate total-amount
Input x
3. A mixture of the both. For example,
Compute total-amount =
item1.price + itme2.price + item3.price
A compound sentence is one of the following:
- Sequence of sentences
- Block sentence
- Conditional sentences (if … then .. else)
- Multiple choice sentence ( switch case)
1
- Iteration sentences (looping)
Structured English Examples:
if x > 5 and y > x + 1 and z > x + y
then
begin
Compute sum = x + y + z;
Output sum;
end
else
begin
Compute sum = x * y * z;
Output sum;
end;
do
begin
Read item-d;
Register item-d in expenses-file
end
while item-d.name <> “end”
end-while;
Advantages of Structured English:
 Clarifying the logic and relationships found in human languages
 An effective communication tool, and easy to teach and understand
4. Decision Tables.
Conditions and actions
conditions
Actions
rules
Condition alternative
Action entries
Rules:
Alternatives number = 2 conditions number
Y means the condition is true
N means the condition is false
X means to perform the action
2
Example 1:
Suppose we want to create a decision table for SBS book store, so:
If the book price is more than 1000, the customer will get a coupon of 50
If the book number is more than 10, the customer will get a delivery
service.
Solution:
We have 2 conditions so Alternatives = 2 2 = 4
Conditions and actions
Book price> 1000
Book number >10
Get delivery
Get coupon
Example
Rules
Y
Y
X
X
Y
N
N
Y
X
N
N
X
2:
Employee
Manager
Not manager
Manager
Not manager
salary
<=500
<=500
501 – 800
501 – 800
additions in salary
50 jd
20 jd
30 jd
30 jd
solution
We have 3 conditions , so 23 = 8 alternatives,
We have 3 actions ( additions either 50 or 30 or 20)
Conditions and actions
Manager
Salary <=500
Salary 501 - 800
30 jd bonus
50 jd bonus
20 jd bonus
Rules
Y Y
Y Y
Y N
X
Y Y
N N
Y N
X
N
Y
Y
N
Y
N
N N
N N
Y N
X
X
We reduce the table by omitting columns of condition alternatives
that have no action to be performed:
3
Conditions and actions
Manager
Salary <=500
Salary 501 - 800
30 jd bonus
50 jd bonus
20 jd bonus
Rules
Y Y
Y N
N Y
X
X
N
Y
N
N
N
Y
X
X
When there is redundancy in actions we can reduce the table if its possible,
Conditions and actions
Manager
Salary <=500
Salary 501 - 800
30 jd bonus
50 jd bonus
20 jd bonus
Example
Rules
Y -Y N
N Y
X
X
3:
Employee
Manager
Not manager
Manager
Not manager
Manager
Not manager
salary
<=500
<=500
501 – 800
501 – 800
>800
>800
additions in salary
50 jd
30 jd
50 jd
50 jd
60 jd
60 jd
4
N
Y
N
X
solution
We have 4 conditions , so 24 = 16 alternatives,
We have 3 actions ( additions either 50 or 30 or 60)
Conditions and
actions
Manager
Salary <=500
Salary 501 – 800
Salary >800
30 jd bonus
50 jd bonus
60 jd bonus
Rules
YYYYYYYYNNNNNNNN
Y Y Y YN N N N Y Y Y Y N N N N
Y Y NN Y Y N N Y Y N N Y Y N N
Y N Y N YN Y N Y NY N Y N Y N
X
X X
X
X
X
We reduce the table by omitting columns of condition alternatives
that have no action to be performed:
Conditions and
actions
Manager
Salary <=500
Salary 501 – 800
Salary >800
30 jd bonus
50 jd bonus
60 jd bonus
Rules
Y Y Y N
Y N N Y
N Y N N
N N Y N
X
X X
X
N N
N N
Y N
N Y
X
X
When there is redundancy in actions we can reduce the table if its possible,
NOTE: rules 1,2, 5 cannot be merged although there is redundancy , but rules 3,
6 can be merged
Conditions and
actions
Manager
Salary <=500
Salary 501 – 800
Salary >800
30 jd bonus
50 jd bonus
60 jd bonus
Rules
Y Y -- N
Y N N Y
N Y N N
N N Y N
X
X X
X
5
N
N
Y
N
X
5. Decision Trees.
6
EXAMPLES of decision table
Merging rules
Why do we merge rules?
We merge in order to reduce redundancy and find the optimal decision table.
We merge by putting ( --) instead of y or n , we mean by this that in this rule
the condition can be yes or no ( don't care rule).
1. merging 2 conditions:
Example 1:
Conditions and actions
Rules
Employee
salary >300
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
1
Y
Y
2
Y
N
X
X
3
N
Y
4
N
N
X
X
To get the following optimal table, There is redundancy ,
SO Rule 1,2 : can be merged
Conditions and actions
Rules
1,2 merged
3
4
employee
salary >300
Y
--
N
Y
N
N
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
X
X
X
7
2. merging 3 conditions
Example 2:
Conditions and actions
married
employee
Salary>300
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
1
Y
Y
Y
X
2
Y
Y
N
X
Rules
4
5
Y N
N Y
N Y
X
3
Y
N
Y
X
THE OPTIMAL TABLE :
Rules
1,2,5,6
merged
3, 7
merged
4,8
merged
-Y
-X
-N
Y
-N
N
X
X
8
8
N
N
N
X
There is redundancy ,
Rule 1,2,5,6 : can be merged
Rule 3, 7 can be merged
Rule 4,8 can be merged
married
employee
Salary>300
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
7
N
N
Y
X
X
Conditions and actions
6
N
Y
N
X
Example 3:
Conditions and actions
1
Y
Y
Y
X
married
employee
Salary>300
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
2
Y
Y
N
3
Y
N
Y
X
X
There is redundancy ,
Rules
4
5
Y N
N Y
N Y
X
X
6
N
Y
N
X
7
N
N
Y
8
N
N
N
X
X
-Y
--
Rule 1,5,6 : cannot be merged into the pattern
because rule 2 can be represented in
this pattern although it has a different action ( see the previous example to compare)
Y
---
Rule 2,3,4 cannot be merged into the pattern
because rule 2 can be represented in
this pattern although it has a different action ( see the previous example
Rule 7,8 can be merged into
N
N
--
THE OPTIMAL TABLE :
Conditions and actions
married
employee
Salary>300
Get free medical treatment
Pay 80% of the bill
Pay 50% of the bill
Rules
1
2
3
4
5
6
7,8
Merged
Y
Y
Y
X
Y
Y
N
Y
N
Y
N
Y
N
X
N
N
--
X
X
Y N
N Y
N Y
X
X
X
9
Download