When the process logic involves formulas or iteration, or when structured decisions are not complex, an appropriate technique for analyzing the decision process is the use of structured English. As the name implies, structured English is based on
- structured logic, or instructions organized into nested and grouped procedures, and
- simple English statements such as add, multiply, and move.
A word problem can be transformed into structured English by putting the decision rules into their proper sequence and using the convention of IF-THEN-ELSE statements throughout.
To write structured English, you may want to use the following conventions:
- Express all logic in terms of one of these four types: sequential structures, decision structures, case structures, or iterations (see the illustration below for examples).
- Use and capitalize accepted keywords such as IF, THEN, ELSE, DO, DO WHILE, DO UNTIL, and PERFORM.
- Indent blocks of statements to show their hierarchy (nesting) clearly.
- When words or phrases have been defined in a data dictionary (as in Chapter “Analyzing Systems Using Data Dictionaries“), underline those words or phrases to signify that they have a specialized, reserved meaning.
- Be careful when using “and” and “or,” and avoid confusion when distinguishing between “greater than” and “greater than or equal to” and like relationships. “A and B” means both A and B; “A or B” means either A or B, but not both. Clarify the logical statements now rather than waiting until the program coding stage.
Structured English Type | Example |
---|---|
Sequential Structure A block of instructions in which no branching occurs | Action #1 Action #2 Action #3 |
Decision Structure Only IF a condition is true, complete the following statements; otherwise, jump to the ELSE | IF Condition A is True |
Case Structure A special type of decision structure in which the cases are mutually exclusive (if one occurs, the others cannot) | IF Case #1 implement Action #1 |
Iteration Blocks of statements that are repeated until done | DO WHILE there are customers. |
A Structured English Example
The following example demonstrates how a spoken procedure for processing medical claims is transformed into structured English:
We process all our claims in this manner. First, we determine whether the claimant has ever sent in a claim before; if not, we set up a new record. The claim totals for the year are then updated. Next, we determine if a claimant has policy A or policy B, which differ in deductibles and copayments (the percentage of the claim claimants pay themselves). For both policies, we check to see if the deductible has been met ($100 for policy A and $50 for policy B). If the deductible has not been met, we apply the claim to the deductible. Another step adjusts for the copayment; we subtract the percentage the claimant pays (40 percent for policy A and 60 percent for policy B) from the claim. Then we issue a check if there is money coming to the claimant, print a summary of the transaction, and update our accounts. We do this until all claims for that day are processed.
In examining the foregoing statements, one notices some simple sequence structures, particularly at the beginning and end. There are a couple of decision structures, and it is most appropriate to nest them, first by determining which policy (A or B) to use and then by subtracting the correct deductibles and copayments. The last sentence points to an iteration: Either DO UNTIL all the claims are processed or DO WHILE there are claims remaining.
Realizing that it is possible to nest the decision structures according to policy plans, we can write the structured English for the foregoing example (see illustration below). As one begins to work on the structured English, one finds that some logic and relationships that seemed clear at one time are actually ambiguous. For example, do we add the claim to the year-to-date (YTD) claim before or after updating the deductible? Is it possible that an error can occur if something other than policy A or B is stored in the claimant’s record? We subtract 40 percent of what from the claim? These ambiguities need to be clarified at this point.
DO WHILE there are claims remaining
IF claimant has not sent in a claim
THEN set up new claimant record
ELSE continue
Add claim to YTD Claim
IF claimant has policy–plan A
THEN IF deductible of $100.00 has not been met
THEN subtract deductible–not–met from claim
Update deductible
ELSE continue
ENDIF
Subtract copayment of 40% of claim from claim
ELSE IF claimant has policy–plan B.
THEN IF deductible of $50.00 has not been met
THEN subtract deductible–not–met from claim
Update deductible
ELSE continue
ENDIF
Subtract copayment of 60% of claim from claim
ELSE continue
ELSE write plan–error–message
ENDIF
ENDIF
IF claim is greater than zero
THEN print check
ENDIF
Print summary for claimant
Update accounts
ENDDO
Besides the obvious advantage of clarifying the logic and relationships found in human languages, structured English has another important advantage: It is a communication tool. Structured English can be taught to and hence understood by users in the organization, so if communication is important, structured English is a viable alternative for decision analysis.
Data Dictionary and Process Specifications
All computer programs may be coded using the three basic constructs: sequence, selection (IF . . .THEN . . . ELSE and the case structure), and iteration or looping. The data dictionary indicates which of these constructs must be included in the process specifications.
If the data dictionary for the input and output data flow contains a series of fields without any iteration—{ }—or selection—[ ]—the process specification will contain a simple sequence of statements, such as MOVE, ADD, and SUBTRACT. Refer to the example of a data dictionary for the SHIPPING STATEMENT, see illustration below.
Shipping Statement = Order Number + Order Date + Customer Number + Customer Name + Customer Address + {Order Item Lines} + Number of Items + Merchandise Total + (Tax) + Shipping and Handling + Order Total Customer Name = First Name + (Middle Initial) + Last Name Address = Street + (Apartment) + City + State + Zip + (Zip Expansion) + (Country) Order Item Lines = Item Number + Quantity Ordered + Quantity Backordered + Item Description + Size Description + Color Description + Unit Price + Extended Amount |
Notice that the data dictionary for the SHIPPING STATEMENT has the ORDER NUMBER, ORDER DATE, and CUSTOMER NUMBER as simple sequential fields. The corresponding logic, shown in lines 3 through 5 in the corresponding structured English in the illustration below, consists of simple MOVE statements.
Structured English
Format the Shipping Statement. After each line of the statement has been formatted, write the shipping line.
1. GET Order Record
2. GET Customer Record
3. Move Order Number to shipping statement
4. Move Order Date to Shipping Statement
5. Move Customer Number to Shipping Statement
6. DO format Customer Name (leave only one space between First/Middle/Last)
7. DO format Customer Address lines
8. DO WHILE there are items for the order
9. GET Item Record
10. DO Format Item Line
11. Multiply Unit Price by Quantity Ordered giving Extended Amount
12. Move Extended Amount to Order Item Lines
13. Add Extended Amount to Merchandise Total
14. IF Quantity Backordered is greater than zero
15. Move Quantity Backordered to Order Item Lines
16. ENDIF
17. ENDDO
18. Move Merchandise Total to Shipping Statement
19. Move 0 to Tax
20. IF State is equal to CT
21. Multiply Merchandise Total by Tax Rate giving Tax
22. ENDIF
23. Move Tax to Shipping Statement
24. DO calculate Shipping and Handling
25. Move Shipping and Handling to Shipping Statement
26. Add Merchandise Total, Tax, and Shipping and Handling giving Order Total
27. Move Order Total to Shipping Statement
A data structure with optional elements contained in parentheses or either/or elements contained in brackets will have a corresponding IF . . . THEN . . . ELSE statement in the process specification. Also, if an amount, such as QUANTITY BACKORDERED, is greater than zero, the underlying logic will be IF . . . THEN . . . ELSE. Iteration, indicated by braces on a data structure, must have a corresponding DO WHILE, DO UNTIL, or PERFORM UNTIL to control looping on the process specification. The data structure for the ORDER ITEM LINES allows up to five items in the loop. Lines 8 through 17 show the statements contained in the DO WHILE through the END DO necessary to produce the multiple ORDER ITEM LINES.