From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,30df5a909ff1af4 X-Google-Attributes: gid103376,public From: Joseph P Vlietstra Subject: Re: Answering an Ada/COBOL Question Date: 1999/11/15 Message-ID: <382FA652.A72E4150@concentric.net>#1/1 X-Deja-AN: 548718516 Content-Transfer-Encoding: 7bit References: <80hr16$5q2$1@nntp5.atl.mindspring.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353" Organization: Concentric Internet Services Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-15T00:00:00+00:00 List-Id: Richard D Riehle wrote: > I once challenged some Ada programmers to come up with an Ada design > that would be as expressive as the Evaluate statement. None of the > solutions was satisfactory. If you think you have a solution that is > as expressive as that in COBOL, be sure you cover all the variations > possible, not simply the one I just demonstrated. Back in the good old days when Fortran was FORTRAN, we designed a sonar simulator strictly using decision tables. While we couldn't directly express the decision table in FORTRAN, we could incorporate the decision table in comments. (In fact, this was required item that was checked in the peer reviews.) Using comments to document the decision table works in any language! We no longer try to use decision tables for everything. But when decision tables are used for design, we still follow these rules: -- decision table is in canonical format ("major" decisions first) -- decision table appears in comments above implementing code -- predicates are evaluated in same order as they appear in decision table In my experience, many decision tables contain "don't care" entries. For example, if Marital_Status = Single then Age_Of_Spouse is a don't care. When a decision table is ordered correctly (don't cares entries in upper right) the implementation drops out. (See "Decision Tables in Software Engineering" or CODASYL publication on decision tables -- I'm at home so I can't grab the exact title from the bookshelf.) For example, the following decision table: A B C T X X Action_1 F T X Action_2 F F T Action_3 F F F Action_4 can be implemented as: if A then Action_1; elsif B then Action_2; elsif C then Action_3; else Action_4; end if; Yes, this example is extreme, but I rarely see a decision table design that doesn't have some don't care entries. Also, in my obsolete COBOL experience, I never implemented an Evaluate statement to test several conditions. It always seemed cleaner to break the logic into nested If and Evaluate statements.