Magic User Group

Magic Wiki-Wakka : IUBasicMechanism

HomePage :: CATEGORIES | Index :: Changes :: Comments :: Search :: Login/Register

Basic Incremental Update Mechanism:


We will illustrate the essence of the Incremental Update mechanism through a simple example.

Example 1: Simple ‘Running Total’.


In this example we will simply accumulate a ‘Running Total’ for list of numerical values entered and maintained by a user in an online task.

Let’s consider the following table with two columns:

Table: List_of_Values

Columns:
1) Code: Alpha (2)
2) Value: Numeric (5)

Provided the table is empty at the time of executing the process described hereafter.

Lets describe a process that allows basic maintenance with regular Creation, Modification and Deletion capabilities at row level during an Online, Line mode session.

In addition to the above, the process must maintain and display an accurate and up to date ‘Running Total’ of all the values entered during the online session.

Logical Considerations:


Before describing how the above running total can be maintained in an eDeveloper task, lets describe the procedural details required to achieve such result:

1) Upon creating a new line (Create mode), the value entered on the new row must be added to the ‘Running Total’ accumulator.
Example:

2) Upon deleting a line, the value that was on this line (prior to its deletion) must be subtracted from the ‘Running Total’ accumulator.
Example:
Deleting the second line (value of 50) of our ongoing example, results in subtracting this value from the actual (170) ‘Running Total’ value. The result is Running Total = 170 – 50 = 120.

3) Upon modifying the value on an existing line, the Net Difference of the modification must be applied to the ‘Running Total’ accumulator. The Net Difference can be described further as:

Net Difference = Final Value – Original Value

For Example:

The result is: Running Total = 120 + (30-20) = 120 + 10 = 130

Notice that the Net Difference can be negative if a Value is modified as such that the Final Value is less than the original Value.

The result is: Running Total = 130 + (60-100) = 130 - 40 = 90

Comments and observations:


1) The above sequence is quite simple to predict, However, it does reveal that even a simple ‘Running Total’ accumulation process must take care of a several scenarios and adjust its execution accordingly in order to guaranty an accurate result.

2) If we list what is required to be known at each accumulation step in order to perform the right calculations, we get:

3) The items of the above list are all items that the eDeveloper engine knows and keeps track of at all time. The Stat() and the Varprev() functions are evidence of such fact.

4) Therefore, it is correct to conclude that the eDeveloper engine knows and is already maintaining everything that is necessary to be able to handle complete and accurate accumulation (“Incremental”) processing.

eDeveloper is not only able to process “Incremental” logic, It actually does it all for us provided we instruct it to:

Update, How = Incremental:


We will now describe how simple it is to add to an eDeveloper task what would support the above-described example.

First create a simple program that provides regular line mode access and maintenance to the List_of_Values table. This can be done through the following steps:

1) Create the previously described memory table with the two columns mentioned (Code and Value)

2) Generate a new program on the above table:

To add the ‘Running Total’ and associated processing logic, we do the following:

1) Add the following:

2) In the Record Suffix add the following operation:
 Update, Running Total,   Exp=Value, How=Incr 

The ‘How=Incr’ parameter is what will trigger the engine to perform ‘Incremental’ accumulation rather that direct assignation logic. The expression referring to the ‘Value’ column informs the engine of the seed (detailed subject) of the accumulation. This will vary from one process to the other and is the responsibility of the developer to properly identify and specify. But the engine automatically and accurately performs everything else.

3) Run the program and see how the running total is properly maintained and displayed as the user enters and modify information on the screen.

Back To: Incremental Update

The original version of this page was provided by: InformaPlus

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki trunk
Page was generated in 0.0572 seconds