Application Logic Example - Technical Rationale

Why?
If one wants to avoid that user interfaces are updated inconsistently, complex libraries need to be used to track changes. These render business logic hard to write maintain, while business logic is actually simple.

With general-purpose programming languages it is quite a challenge to implement for every interaction code to update the program and its user interface such that all changes made in the UI and in the data model of an application are correctly shown in the UI. Without advanced support like MVC and constraint libraries one easily get applications that suffer from inconsistent behavior and applications that are hard to maintain. However programming on top of these advanced libraries increase the complexity of the program and clutters the application logic with a lot of technicalities. In conclusion, one either gets a program that is hard to maintain or a complex program.

Examples
Online forms with computations, applications with rich user interactions, etc.

When using general-purpose programming languages programmers have to mentally track every change in de UI and in the data in order to consistently update the program and its user interface. For example, consider a next button for database record navigation. Whenever this button is pressed, a counter should be incremented moving to a new record. This is the behavior one would expect. However, besides the updating the counter the programmer needs to carefully update the current record, reinitialize the UI with the new record data, grey out the button when it hits the end of the record stream, etc. One can easily forget an update resulting in inconsistent behavior. Later when adding a new field one might easily forget to modify the behavior of the next button. More over there can be many other interactions that need similar behavior such as a previous button, jumping to a record, updating fields that are dependent on one another, etc.

What?
New language constructs are implemented as a library such that computations constantly re-evalute.

Application logic can be represented with web equations - an embedded language in Javascript to configure the behavior of programs by establishing permanent relations between various data and how it is shown in the UI. For example, in this expression total.equals(sum(subtotal,discount)) the total always equals the sum of variable subtotal or discount during the lifetime of a program. For example, in this expression total.equals(sum(a,b)) the total is recomputed whenever the variable subtotal or discount changes. There is thus no need to manually keep track and trigger what has to be recomputed.

The language has a user friendly notation that hides the technicalities to use the above mentioned libraries. By embedding the language, it can easily be complemented, extended and altered with normal javascript code. For example, the above sum function of our example is defined using plain javascript.

How?
Layer hiding the complexities of constraint libraries.

The language is implemented on top of a constraint library. Unlike conventional languages, computations are automatically recomputed each time something changes. So instead of having to learn how to use the library, the language applies the library for you to your problem. On top of the constraint library a small layer is implemented that offers new programming constructs e.g. equals(). The library contains about 50 lines of code and at its core configures the automatic tracking of variable changes and triggers recomputation.

Benefit
Keeping a user interface in sync with data no longer requires in-depth programming expertise about complex libraries.

The code now only contains the business logic of an application. Moreover such programs can be more easily changed and extended. It suffices to add an additional relationship. No need to touch or change other code, as changes to data will automatically be handled by other relationships. For example, consider a program that shows the current selected item of a list. It has one relationship between the display and the current selected list value. Adding a button requires only new relationship between the button and list index. Whenever the button is pressed, changes to the selected list item will be handled by the already existing relationship.


Homepage // Motivation // Our Services // Examples // Design Tools // Contact
© Copyright 2011, Sebastian Günther & Thomas Cleenewerck, Software Languages Lab, All rights reserved