db Systems

Creators of Software

Home

Services

DTC

FAQ

About

Contact

Business Use

Information technology (IT) groups need requirements.  When conditional logic comes into the picture, the requirements are usually wanted as flow charts, process flows or UML activity diagrams.  Requirements are supposed to answer "what" not "how".  However, flow charts, process flows and UML activity diagrams are "how" to do things.

Business users like to use spreadsheet programs to do everything from analysis to reporting. Why not use a spreadsheet to create "tables" (decision tables) to specify "what" is required? But decision tables need to be converted into the "how" IT needs.

The DTC creates procedure (the how) from a table-like description of decisions and conditions (the what). This is a tedious and thankless job. (Ask any analyst!)

Consider a simple example.  Imagine a traffic signal with the standard colors red, yellow and green having the usual meaning, red indicates stop and green go.  Yellow indicates a change to red will occur soon.  Given the only decision is to stop or go, yellow creates opportunity for panic.  To resolve the ambiguity a simple rule is added.  During the day, go on yellow and stop otherwise:


  ACTION    SIGNAL    DAY 
 
GO
 
GREEN
 
 
GO
 
YELLOW
 
YES
 
STOP
 
YELLOW
 
NO
 
STOP
 
RED
 


Converting this into a flow chart or text description (by visual inspection of the table) yields something like:

if Signal is Green then
Go if Signal is Yellow and Day is yes then
Go if Signal is Yellow and Day is no then
Stop if Signal is Red then
Stop


Even though this implementation is easy to create, it requires, in the worse case, six decision points!  Perhaps using the "else" notion may cut the number in half:

if Signal is Green or (Signal is Yellow and Day is yes) then
Go
else
Stop



 


This case is much better, requiring in the worse case, only three tests.  Not so obvious is a version where the worse case is only two:

if Signal is Yellow then

if Day is Yes then Go else Stop else if Signal is Red then Stop else Go


The last implementation is not as understandable (humanly) as the second, but this simple example demonstrates a need for a better way to convert conditional decisions into procedure.  The DTC provides a better way.

The easiest way to construct a decision table is with a "
spreadsheet" program.  Given all these tools can output a TAB delimited version of the sheet allows freedom of choice among the "spreadsheet" programs.

View this example as a
spreadsheet.

The text in column A cells, except the first row, are the possible values for the sheet up to an optional @MAP text. The first row indicates if the sheet makes a decision (@OUT in the Action sheet) or depends on external input (@IN in the Signal and Day sheets).

The @MAP rows declare the sheet names where the text for the columns come from. The cells below that column are validated by the DTC against the text in the named sheet. Most spreadsheet programs can be configured to make the values in the columns a drop down (validated) against the values in the referred sheet, even though Google spreadsheet is unable at this time.

The rows below the first @MAP row can be interpreted as: "Go if Signal is Green OR Stop if Signal is Red". The rows below the second @MAP row can be interpreted as: "Go if Signal is Yellow AND Day is Yes OR Stop if Signal is Yellow AND Day is No". The technical term for this type of arrangement is
disjunctive normal form.


Technical Use

An important feature of spreadsheet programs is the ability to lock header rows and columns as the cells are scrolled.  This makes it relatively easy to handle large numbers of conditions and decisions.

However, humans are not good at dealing with more than about seven things at a time. There must be a way to manage the complexity of specifications.  The best way of doing this is to allow decomposition of a problem.  The idea is to allow the results of dependent decisions to roll-up into the conditions of depending decisions.  This is simple with the spreadsheet metaphor, simply give decision tables names and allow the conditions of tables to use the decisions of others.  The implication is there are many decision tables in a complex system and they are usually interdependent.

But dealing with decomposition is where most implementations of decision tables are not adaptable to future change.  The usual way is to separate modules on the specification's decomposition.  This is where structure comes into the picture.  The idea is to reflect the same human need to decompose and encapsulate.  The resulting implementations contain the human structure.  However, computers are not human and have no need for this.  The structure also drives the need for engineering and architecture.  It makes software less efficient and hard to change.  It also makes parallel evaluation of interdependent decisions extremely difficult.

The Decision Table Compiler (DTC) addresses these issues by generating code from decision tables that do not contain the decompositions and do not create intermediate results.  As most decision tables are sparse, there are opportunities for optimization.  The DTC works to optimize the worst case evaluation process in a specification.  In the sparse case, the resulting code also contains redundancies.  The DTC eliminates these common sub-expressions and the resulting code is smaller.  Finally, all the decision tables of a specification are evaluated in parallel.

The bottom line is the implementation of the decision tables runs fast, takes up little space and is correct.

What follows is a very detailed example to demonstrate some of these points.

This problem came from Simon Tatham regarding
equivalence relations. What follows is not an answer to his question but addresses the issue of problem decomposition. He gives an example of matching a string to a regular expression, 0[xX][0-9A-Fa-f]+|[1-9][0-9]*|0[0-7]*. There are specialized ways to do this but the DTC can be used to build state machines, which is what a regular expression match algorithm is.

This example uses C, but most any language can be used with the templates (see below). To use the DTC for a state machine, implement a loop where the decision is provided by the DTC code. The loop could be something like:

{
enum state theState;
char *c;


for (theState = START, c = string; *c && theState != NOMATCH; c++) {
#include "equivalence.c"
}

}

Where the code generated by the DTC is in the file equivalence.c. The loop uses the state and the next character to advance the state machine.

The DTC specification is in this
spreadsheet.

There is a sheet named CharacterClass which (referring back to Simon's page) specifies the decomposition Simon suggests, specifically [0], [Xx], [A-Fa-f], [1-7], [8-9] and other (the @ELSE value). The sheet indicates it is an @OUT, meaning a decision is being made but there is no "code" (template fragments you see in column B of the other sheets), so this is only an internal decomposition used by the developer.

Indicating the output should be "nested" when the DTC is run causes the output to use a nested if style. The output is in
equivalenceNested.c. Notice there is no trace of CharacterClass in the output.

The DTC defaults to descriptive templates but these can be changed by @ directives in a sheet named DtcTemplate. The default templates and their values are:

@PRESTR table %s, depth %d, nodes %d
@ELSESTR else %s/%s
@ENDSTR end %s/%s
@PRECOMSTR comment start
@POSTCOMSTR comment end
@GOSTR go to label%d
@LABSTR label%d
@POSTSTR end table %s

The templates are C printf format strings (the DTC is written in C). Comparing the templates in the sheet DtcTemplate, the templates and text in the B columns and the output one can see how they correlate.

The final point to demonstrate has to do with sub expression elimination. In a nested if style there is no way to eliminate common code that occurs with sparse specifications.  The DTC generates "flat" code (using the @GOSTR and @LABSTR templates) if the nesting indicator is not used. The output is in
equivalence.c. Note the nested version is now a comment block and the common sub-expressions are indicated.

This "goto" style code makes developers cringe, as it should. However, the DTC is a compiler. The output only needs to be correct and efficient. The source is the spreadsheet (or a TAB delimited file created with any editor) and is easy to maintain.

Looking at the code it may seem strange to test each character for each value. The assumption is the "character" input needed that kind of detail and the characterClass is just one of the ways the characters are used. If there is no other dependency on the characters other than the class then the specification can remove the detailed character sheet and change the characterClass to an input. The OutputState doesn't need to change. Here is the spreadsheet. The output is equivalenceDirect.c.

orange prada shirt gucci ceny cork board black outlet online usa volcom outlet store outlet fashion online fried and williams mosaic tampa fl aaa catalina express discount prada sling comprar instagram followers instagram 50k followers prada jordans hugo boss factory outlet blue prada wallet prada broadway prada valentine tx indigo pantone color analyze instagram followers tack boards prada sunglasses discount define prada prada blue glasses furla handbags outlet make up fx ymca englewood fl prada reissue gucci .com usa tienda tommy cerca de mí prada sunglasses bloomingdale's prada cat eye boat captain shirt with epaulets prada snakeskin bag prada designer glasses million followers instagram instagram mutual followers best prada perfumes instagram get followers instagram statistics followers chatgpt for free prada purfume chatgpt ticker symbol vintage prada dress high end outlet prada heels platform prada pr 17 prada ring womens print and mail concepts cardinal buildings prada bags cost prada chess set versace purse outlet prada paintings weird spiky fruit prada runway glasses chatgpt sydney chatgpt + midjourney rosemont bars cmyk for reflex blue official prada website prada shoes leather prada lg phone balenciaga official site followers likes instagram prada denim bralette fabric cork boards edward tian chatgpt pie jesu domine dona eis requiem translation instagram mutual followers likes followers instagram manatee high school focus tods shoes outlet gucvi whackbat prada sunglasses gold chatgpt sql prada ambassador prada dallas prada crewneck englewood ymca jack spade brief chatgpt ban fluffy prada bag prada denim bra 1k instagram followers handbag outlets online alyssa craig catalina island visitors guide prada kiss perfume prada logo mule online shop gucci used prada handbags prada heel boots prada sunglasses rectangular specialty printing services cheap prada outlet prada prada clearance tienda de gucci


Copyright (c) 2019 db Systems.