1 / 16

Systems Analysis & Design Methods

Systems Analysis & Design Methods. II Coping with complex conditions: Decision tables. Contents. Decision Tables Example Context and history Possible implementations Evaluation & alternatives. Example: Bank account rules.

saxon
Download Presentation

Systems Analysis & Design Methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Systems Analysis & Design Methods II Coping with complex conditions: Decision tables

  2. Contents Decision Tables • Example • Context and history • Possible implementations • Evaluation & alternatives Systems Analysis II Decision Tables

  3. Example: Bank account rules I) If a client has an account for over 10 years (ay>10) and his salary is deposited on this account (sd=Y), he gets a bonus of 10000, except if his balance was negative during more than 3 months (nbm>3), in which case his bonus drops to 5000. II) The bonus is 5000 for clients who have an account for more than 3 years, except if their balance was negative for at least 1 month, in which case the bonus drops to 2500. III) No bonus is granted to anyone with a balance that has been negative for over 5 months. Systems Analysis II Decision Tables

  4. Example: Bank account rulesvariables and categories There are three variables, yielding three variable rows. For every category within a variable, the columns are split up, yielding 3 x 4 x 2 = 24 columns • ay: <3 ; 3 <= ay <= 10 ; ay > 10 • nbm: <1 ; 1 <= nbm <= 3 ; 3 < nbm <= 5 ; nbm > 5 • sd: Y ; N Systems Analysis II Decision Tables

  5. Full, unchecked table: Systems Analysis II Decision Tables

  6. Full, unchecked table:Remarks • Contains every possible case. • Marks with an x only these cases that are mentioned in the text. • May contain inconsistencies. E.g. In our example • case 15 & 16: you get both 0 and 2500. • J(a) means Y(es). Systems Analysis II Decision Tables

  7. Checked Table Systems Analysis II Decision Tables

  8. Checked Table:Remarks • Maximum one value per column Solves consistency poblems. Examples: • Case 15 & 16: 0:x, 2500:x -> Choose 0 Reason: Sentence III explicitly states that no one, having a negative balance for over 5 months, is to have a bonus. That’s why we choose 0 and not 2500 as the bonus in case 15 & 16 • Case 17: 5000:x, 10000:x -> Choose 10000 Reason: This time, no sentence is more explicit then another. Common sense tells you to take 10000 • … Systems Analysis II Decision Tables

  9. Checked Table:Remarks • Minimum one value per column If no bonus is granted, we want this to be explicit. We want to avoid blank columns. In our table: • Cases 1 to 6: no box marked -> Choose 0 All other boxes get hyphens. Now, every case (column) is assigned exactly one bonus. Systems Analysis II Decision Tables

  10. Reduced Table Systems Analysis II Decision Tables

  11. Reduced Table:Remarks • Since we now have only one x per column, we can move the appropiate bonus-value to the column, reducing the rows. • Criteria that do not matter, are given a hyphen sign (-), meaning “don’t care”. Examples: • Cases 1 to 8: All cases result in 0 bonus no matter what the values of nbm or sd are. The 8 colmuns are merged • Cases 9 & 10: Given 3 <= ay <= 10 and nbm < 1, sd is of no importance anymore … ( Premie means bonus here) Systems Analysis II Decision Tables

  12. Reduced Table with Optimal Condition Order Systems Analysis II Decision Tables

  13. Reduced Table with Optimal Condition Order: Remarks • By swapping criteria, some condition testing can be avoided. Just once here: • Swapping nbm and sd, reduces the categories from 4 to 3 in the case of ay > 10 Systems Analysis II Decision Tables

  14. To working code • See Customer.java • Homework: • Correct possible mistakes • Try the three alternatives • Invent entirely other ways to code it. • Turn the main program to a decent testing program. Systems Analysis II Decision Tables

  15. Evaluation and alternatives • Problem : repetition of conditional code. In real life, the same conditions tend to come back in different places in your code. In fact when coding conditional code, you will notice that entire structures of if-then-else nesting come back time after time. This is code repetition or copy-pasting of code, which is a maintenance nightmare. Systems Analysis II Decision Tables

  16. Problem: repetition of conditional code • Non OO solution: Write the conditional code in a procedure once and pass function pointers to it. These function pointers enable you to call any function within the complex conditional structure. N.B. Languages who don’t support function pointers can use eval()-mechanism for evaluation of code, hidden in strings. Or they can use a special case structure to decide which code to call. • OO solution: Use inheritance in stead of conditions. The polymorphism mechanism removes the need to call function pointers. Systems Analysis II Decision Tables

More Related