Search This Blog

Tuesday, June 19, 2012

Error tolerant programming

One of principles of AMODIT is to make it as easy as possible. You can start using workflow in a few minutes and end users can propose new procedure giving it just a name and names of possible stages.
However, later some procedures get more mature and stable and we want to add some automation. This is why AMODIT is equipped with rules engine and special scripting language. Syntax is similar to C#, but is simplified. For example there are no loops, not to let user a chance to make infinite loop.

For those who are familiar with C# it is known that you have to put semicolon ";" after every statement.
For example:
a = a + 1;
b = a * 2;

But we assume that AMODIT users don't have to be experienced programmers and they can forget about semicolons. So compiler is trying to guess if there should be a semicolor and put it there itself. Thus previous example can be simply writtten as:

a = a + 1
b = a * 2

Another thing that is made simple is referring to form fields. Generally if you want to refer to a field you use its name in square brackets:
[field1] = [fields2] + 1;

However, there are some functions which perform special actions with fields. For example SignField(field,comment) function puts a signature into a sign field. First parameter is a name of a field (not its value) so you have to put is as a string:
SignField("field1","my comment");

But users very often make mistakes writing:
SignField([field1],"my comment") 
SignField("[field1]","my comment") 

From syntax point of view it is error. But it is common error and we decided to make compiler smarter.
So now you can use all combinations:

  1. SignField("field1","my comment");
  2. SignField([field1],"my comment") 
  3. SignField("[field1]","my comment") 

Just the first one is really valid, but all others are tollerated because compiler can clearly recognize user's intention. And this is what I call "error tolerant programming"!

No comments:

Post a Comment