Coding Conventions
Posted in News on November 4, 2020 by Henk Verlinde ‐ 3 min read

Naming
Definitions
Camel case
Each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation.
Example: thisIsAnExample
Pascal case
The same as the camel case with the exception that the first letter is capitalized.
Example: ThisIsAnExample
Lowercase
All letters are lowercase, with no intervening spaces or punctuation.
Example: thisisanexample
Conventions
Language construction | Style |
---|---|
Variable name | Camel case |
FETCH column aliases | Camel case |
Type names | Lowercase |
Type variables | Camel case |
Method and Function names | Camel case |
Method and Function parameter names | Camel case |
Import aliases | Camel case |
Workflow names | Pascal case |
White-space
A single white-space should be put before and after punctuation or symbols.
Global rules
- No white-space before semicolon (;)
- No white-space before or after function call operator (→)
- No white-space before or after parenthesis
In assignments
White-space should be added before and after the equals (=) symbol.
Correct
var a = "test";
Incorrect
//No space before or after
var a= "test";
var a="test";
var a ="test";
In expressions
White-space should be added before and after operators.
Correct
var a = (1 + 1) * 2;
if (a > 10 or a < 10) return 0;
Incorrect
//No space before or after
var a = (1+1)*2;
if (a>10 or a<10) return 0;
New lines
- No new lines should be added before open curly braces.
- Close curly brace should always be on new lines and should be followed by new line.
- Two consecutive new lines are forbidden.
If-else statement
Correct
//Example 1
if (true) {
//main path
}
else {
//alternate path
}
//Example 2
if (condition1) {
//first condition path
}
else if (condition2) {
//second condition path
}
else {
//alternate path
}
Incorrect
//Example 1
if (true)
{ //Open curly brace is on a new line
}
else {
system->error("Some error"); } //Close curly brace is NOT on a new line
//Example 2
if (true) {
} else { //Close curly brace is on a new line but NOT followed by a new line
system->error("Some error");
}
FETCH expression
Depending on the size of your FETCH expression you have more choices.
Short single entity FETCH expressions should be written on the same line as the variable declaration. If the length of the variable declaration, assignment and FETCH expression exceeds 80 characters the variable declaration and assignment should be on one line and the FETCH expression on a new line with a single indentation.
//Short single entity, does not exceed 80 chars
var entities = FETCH entity (name) FILTER AND (key == 100);
//Short single entity, exceeding 80 chars is broken in two lines
var entities =
FETCH entity (name, is_public, is_customizable) FILTER AND (key == 100);
//Short single entity, exceeding 80 chars is broken in three lines
var entities =
FETCH entity (name, is_public, is_customizable)
FILTER AND (key == 100);
Multiple entity FETCH expression should always be broken in multiple lines.
var entities =
FETCH entity (name AS entity_name) {
entity_property TO id_entity (name AS property_name)
}
FILTER AND (key == 100);
Methods or Functions
- Methods and Functions should have new lines before and after
Correct
workflow Demo;
method main() {
this->pocess();
}
function process() as int {
return 0;
}
Incorrect
workflow Demo;
//Example 1
method main() {
this->process();
} //No new line between methods
function process() as int {
return 0;
}
//Example 2
method main() {
this->process();
}
function process() as int { //Two or more new lines between methods
return 0;
}