The Rules module

invoice total 01

LF‑ET gene­rates the rules module from the deci­sion ta­ble as a class with

  • an 'execute-method' which receives an implementation of the interface as a transfer value

  • an 'IF-ELSE-tree', whose best possible structure (sequence and nesting of conditions) at each gene­ration is completely recomputed

The IF-ELSE-tree works exclusively with the generated interface methods.

7 rules ⇒ 7 program branches

The deci­sion table has 7 rules – the IF-ELSE-tree 7 program branches that exactly match them:

// *** WARNING: DO NOT MODIFY *** This is a generated Java source code! 
// 
// Generated by LF-ET 2.4.1 (260219a), https://www.lohrfink.de/lfet
// From decision table
//  "/src/main/resources/lfet/demo/InvoiceTotal.lfet"
// 24.02.2026 15:20
// 

// Prolog Standard ---->
// profile LFET.Java.Prolog.Standard.Interface.Dt.ini not found
// used LF-ET 2.4.1 (260219a) build in default

package lfet.demo;

import javax.annotation.processing.Generated;

@Generated("LF-ET")
public class InvoiceTotal_rulesEngine
{
    public void execute(InvoiceTotal_iFace iface)
    {

    // Prolog Standard <----

        if (iface.isPurchaseOrderValue_Less2000())
        {
            // Rule R01 ---->
            
            iface.doTrace("InvoiceTotal", "20260224.152032", 7, 1);
            
            iface.doCalculateShippingCosts();
            iface.doInvoiceTotal_Upd();
            
            // Rule R01 <----
        }
        else if (iface.isPurchaseOrderValue_20007500())
        {
            if (iface.isDiscount_Greater0())
            {
                if (iface.isDiscountType_PercentageDiscountOnThePurchaseOrderValue())
                {
                    // Rule R02 ---->
                    
                    iface.doTrace("InvoiceTotal", "20260224.152032", 7, 2);
                    
                    iface.doApplyDiscount();
                    iface.doCalculateShippingCosts();
                    iface.doInvoiceTotal_Upd();
                    
                    // Rule R02 <----
                }
                else // Discount type EUR - fixed amount, will be deducted from the purchase order value
                {
                    if (iface.isDiscountLessPurchaseOrderValue())
                    {
                        // Rule R03 ---->
                        
                        iface.doTrace("InvoiceTotal", "20260224.152032", 7, 3);
                        
                        iface.doApplyDiscount();
                        iface.doCalculateShippingCosts();
                        iface.doInvoiceTotal_Upd();
                        
                        // Rule R03 <----
                    }
                    else // Discount < Purchase order value N - No
                    {
                        // Rule R04 ---->
                        
                        iface.doTrace("InvoiceTotal", "20260224.152032", 7, 4);
                        
                        iface.doCalculateShippingCosts();
                        iface.doInvoiceTotal_Upd();
                        
                        // Rule R04 <----
                    }
                }
            }
            else // Discount none - no discount given
            {
                // Rule R05 ---->
                
                iface.doTrace("InvoiceTotal", "20260224.152032", 7, 5);
                
                iface.doCalculateShippingCosts();
                iface.doInvoiceTotal_Upd();
                
                // Rule R05 <----
            }
        }
        else // Purchase order value > 75.00 - high
        {
            if (iface.isDiscount_Greater0())
            {
                // Rule R06 ---->
                
                iface.doTrace("InvoiceTotal", "20260224.152032", 7, 6);
                
                iface.doApplyDiscount();
                iface.doInvoiceTotal_Upd();
                
                // Rule R06 <----
            }
            else // Discount none - no discount given
            {
                // Rule R07 ---->
                
                iface.doTrace("InvoiceTotal", "20260224.152032", 7, 7);
                
                iface.doInvoiceTotal_Pov();
                
                // Rule R07 <----
            }
        }

        // Epilog Standard ---->
        // profile LFET.Java.Epilog.Standard.Interface.Dt.ini not found
        // used LF-ET 2.4.1 (260219a) build in default

    }
}

// Epilog Standard <----

// End of generated Java source code
// Generated by LF-ET 2.4.1 (260219a), https://www.lohrfink.de/lfet

 

  • This software does not age!

    • Thanks to complete recal­cu­lation and regene­ration with every functional change

  • GUARANTEED:

    • Permanent 100% correspondence with the functional specification

    • The same logical quality as the deci­sion ta­ble: complete, free of redundancies and contradictions

    • Always perfectly fulfilled: Bidirectional traceability

  • GUARANTEED: Optimum performance

    • No rules engine, no rules server ⇒ just plain code

    • The effort to find the right rule every time is not provided permanently at runtime, but only once during generation:

      • Computing the best possible sequence and nesting of conditions

      • Smallest possible number of condition evaluations at runtime

The Trace code

    }
    else // Discount type EUR - fixed amount, will be deducted from the purchase order value
    {
        if (iface.isDiscountLessPurchaseOrderValue())
        {
            // Rule R03 ---->

            iface.doTrace("InvoiceTotal", "20260224.152032", 7, 3);

            iface.doApplyDiscount();
            iface.doCalculateShippingCosts();
            iface.doInvoiceTotal_Upd();

            // Rule R03 <----
        }
        else // Discount < Purchase order value N - No
        {

The trace code does not have to be used, but that would be a shame since the benefits are enormous:

  • Always perfectly positioned auto­mati­cally

    • the first statement in each rule

    • before the first action is executed

    • i.e. the combinatoric of all input values and thus the rule to be executed is finally fixed

    • all objects in question are still “untouched” BEFORE being processed by the rule

    • in debugging, this would be called a perfect break point

  • In order to be able to follow software behaviour

    • the trace output logs

    • and the deci­sion tables are sufficient

    • no need to analyze source codes anymore

    • also – in most cases – repeated runs for reproducing and analyzing misconduct are no longer necessary