Programming

In order to generate a program code from a decision table, at least one corresponding source element must be present for each condition and each action. See also Preconditions for program code generation

Numerous optional source elements furthermore ensure that more complex or nested components can also be ge­ne­ra­ted directly from LF‑ET.

01

This decision table should serve as the template for the clarification of programming and code generation with LF‑ET: The new status should be agreed on the basis of the current status of traffic lights.

To be able to generate the program code from the decision table, the following source elements must be defined only once e.g. for Java:

  • a prolog (class definition, method signature, etc.) and

  • a logical expression for each condition and

  • one (or more) statement(s) for each action and

  • an epilog (method end, class end, etc.)

  • The source elements can (but need not) be saved directly in the decision table as additional information on the respective conditions and actions.

  • Either the integrated LF‑ET source editor directly or any development environment, such as Eclipse, IntelliJ, JDeveloper or NetWeaver, can be used to edit individual source elements.

  • There are several possibilities to see all source codes of a decision table at a glance:

Determining programming languages

In the case of every decision table you can determine individually for which programming languages source codes are to be ge­ne­ra­ted.

If only the ‘Add’ submenu item is shown under the ‘Source code’ menu item, this means no programming languages have been selected for the current decision table.

All programming languages licensed for LF‑ET are made available for selection under ‘Add’; in our example, ‘Java’ is selected:

01

Once programming languages have been selected and used, they appear automatically under the ‘Source code’ menu item. In our example, ‘Java’ is now displayed as a programming language which has been used:

02

The ‘Update’ function refreshes the list of programming languages used, in particular, languages that have been selected but not used are removed from the list.

Icons

The following icons are used to navigate over source codes:

Icon Meaning

01

Must (mandatory) source code is not defined

02

Must (mandatory) source code is defined

03

Optional source code is not defined

04

Optional source code is defined

Conditions

In the case of every condition a logical argument must be defined for the desired programming language.

A logical argument is defined as the expression provided between IF and THEN: IF logical argument, THEN.

From the context menu for each condition, selecting Source code > Language > LogArg for… opens the internal Source code editor and the logical argument can be entered or edited:

01

In the case of extended conditions for the final value (the 'else value') no logical argument should be defined – just as in the case of the ‘no value' of a restricted condition. If there is no logical argument for the final value, LF‑ET generates an ELSE-statement automatically. The definition of logical arguments for these “else values’ is not recommended; the possibility of doing so has only been retained so that – historically – existing decision tables containing extended conditions need not necessarily be changed.

Hints for defining logical arguments
  • We recommend that logical expressions are put in brackets.

  • LF‑ET checks brackets when generating and adds them automatically, if necessary. However, brackets are then inserted in separate lines before and after the logical argument. Though that seems slightly unusual at first sight, it is necessary in order e.g. to allow comment lines within logical expressions.

Prolog condition (optional)

A “prolog” (preprocess) can be defined for each condition. When code lines are ge­ne­ra­ted, this prolog is integrated directly into the source code in front of the corresponding condition.

A condition may be preceded by an arbitrarily complex process, e.g. DB accesses, calls, evaluations, calculations, …​

01

  • A conditional prolog serves only to prepare the logical evaluation of a system condition (e.g. database accesses or complex arithmetical operations before the evaluation of variable and field contents).

  • The advantage here is that the prolog is e­xe­cu­ted only when it is really needed, i.e. when the condition is relevant for the current processing situation (i.e. program branch).

  • Each conditional prolog must be self-executable. It must not assume any other conditional prolog, nor be assumed in any other process (for example, in an action).

Actions

In the case of every action at least one statement must be defined for the desired programming language.

In the context menu of all cells of an action the corresponding editor can be opened and the source code entered under Source code > Language > StmtSeq…​

01

Additional information:

Prolog decision table (optional)

A “prolog” (preprocess) can be defined for a decision table. It is used as the first statement sequence in the ge­ne­ra­ted program code.

In principle, the decision table prolog (with epilog) can be understood as a “shell” in which opening (prolog) and closing (epilog) definitions, statements, brackets etc. can be used.

In the context menu of the header of a decision table the corresponding editor can be opened and the source code entered under Source code > Language > Prolog…​

01

Epilog decision table (optional)

An “epilog” (post process) can be defined for a decision table. It is used as the last statement sequence in the ge­ne­ra­ted program code.

In the context menu of the header of a decision table the corresponding editor can be opened and the source code entered under Source code > Language > Epilog…​

01

Trace/Debug (optional)

A trace/debug code can be defined for a decision table. This source code is ge­ne­ra­ted as the first statement sequence in every rule and is thus e­xe­cu­ted for the runtime prior to actions.

A detailed analysis of e­xe­cu­ted decision tables and their rules is possible thanks to the use of placeholders.

This serves as powerful support for
  • Tracing and debugging of complex processes.

  • Statistical analyses e.g. for determining the level of test coverage.

In the context menu of the header of a decision table the corresponding editor can be opened and the source code entered under Source code > Language > Trace…​

01

Hints and tips:

  • Rarely needed, but still helpful: The optional prolog in the case of conditions offers an extra possibility, in addition to trace code, to create or remove information on system statuses from the condition prolog.

Error handling (optional)

This section is only relevant in the exceptional case that for a decision table with at least one extended condition a source element was also defined for the last value, the so-called else value, and therefore LF‑ET cannot generate an ELSE branch for this condition.

It may only happen in the case of such decision tables that none of the rules is e­xe­cu­ted and LF‑ET generates a corresponding checking mechanism in the program code that checks rule execution. If no rule has been e­xe­cu­ted, error handling is triggered. You can determine individually what exactly happens in the case of such error handling.

In order to be able to use your own error handling, you must either enter an individual error code in the decision table or create an ini file with the corresponding error.

Contents of this chapter:

Individual error handling

In the context menu of the header of a decision table the source code can be entered by clicking Source code > Language > Error…​

01

INI file for error handling

To ensure the secure and systematic handling of errors when ge­ne­ra­ted program code is e­xe­cu­ted, there is a customizable, in-built error handling functionality in LF‑ET. de­pen­ding on the configuration, one of three possible error handling procedures is used du­ring program code generation:

To take into consideration the error code du­ring generation of the program code, LF‑ET follows the following sequence:

Sequence Action

1.

Search for error codes contained directly in the decision table. If there are none, …

2.

…​search for an error profile LFET.<Programming language>.Error.ini (Example for Java: "LFET.Java.Error.ini") if no ini file is found, finally…​

3.

…​LF‑ET – standard error handling is used

The variant used is explained in detail in the form of a comment in the ge­ne­ra­ted program code.

Integrated source code editor

There is an integrated editor in LF‑ET for the processing of source codes in which all text editing mechanisms and navigation elements are available.

01

To facilitate navigation, the following are specified in the title line of the source code being processed: the programming language and the assignment to a condition, action, etc.

Icons used for navigating over source codes can be found in the symbol bar. You can e.g. go directly to the next source code, to the next mandatory source code or to the next empty mandatory source code.

The respective technical description for the source code to be entered is displayed in the gray box below the symbol bar. This text area is not editable and contains important information that considerably supports the programming or code review. Hence, there is no need to exit the editor in order to save all sources and texts.

You can switch directly to texts, value tables and other programming languages via the menu bar and Edit.

02

Alternatively, all source codes can be edited “externally” in any development environment. For more information see the section: External programming

Contents of this chapter:

Expanded text display

The section Texts shows how extra information in text form can be added to elements of a decision table.

When processing source codes this additional text information can be displayed. In the example below, the title of a condition can only be seen via the entry area of the source code. However, the up and down pointing arrows on the right-hand side indicate that there is additional text.

01

Contents of this chapter:

Possibility 1: as a tooltip

If you want to see the text only briefly, you can place the mouse pointer on the text and display the underlying text as a tooltip.

01

Additional information:

Possibility 2: Augmenting the text area

If necessary, the text area can be enlarged so that the text is visible permanently.

01

Additional information:

There is an integrated editor in LF‑ET for the processing of source codes in which all text editing mechanisms and navigation elements are available.

There is no need to exit the editor in order to navigate over source codes. Icons used for navigation can be found in the symbol bar. They have the following meaning:

Toolbar icon Explanation

01

Switch to previous source code ( CTRL+PAGE UP )

02

Switch to next source code ( CTRL+PAGE DOWN )

03

Switch to previous filled source code ( CTRL+SHIFT+PAGE UP )

04

Switch to next filled source code ( CTRL+SHIFT+PAGE DOWN )

05

Switch to previous mandatory source code

06

Switch to next mandatory source code

07

Switch to previous empty mandatory source code

08

Switch to next empty mandatory source code

Key combinations in the source code editor

Toolbar icon Explanation

F1

Launch Help

CTRL+F1

Launch Help separately

ALT+F4

Save and exit editor

CTRL+A

Select the whole editor area

CTRL+PAGE DOWN

Go to next source code

CTRL+PAGE UP

Go to previous source code

CTRL+SHIFT+PAGE DOWN

Go to next filled source code

CTRL+SHIFT+UP

Go to previous filled source code

CTRL+C

Copy selected character string to clipboard

CTRL+G

Save current decision table and generate current language

CTRL+ALT+G

Save and exit source code editor and display scrapbook menu

CTRL+SHIFT+G

Save current decision table and generate all languages

CTRL+S

Save and exit source code editor

CTRL+V

Paste character string copied to clipboard

CTRL+X

Cut character string and copy to clipboard

CTRL+Y

Redo changes

CTRL+Z

Undo changes