...
This page provides recommended styles for key functional elements.
General
- Add comments (// and /* ... */) to scripts
- Include blank lines between statements
- Use spaces within expressions
- Indent sub-clauses by 4 spaces
- Ensure that attributes which represent the same thing in different Streams, have the same name - this is necessary when doing a Union in a calculate stream but is also important in other types of merge
- Add descriptions to all models
- Add descriptions to all model elements. Item properties
- All items in PhixFlow have a description property. We recommend you add a description to any item you create.
Anybody looking at a model or application will first look at the descriptions of the
- items within it. For example, in an analysis model, they should be able to discern the flow and the high-level logic of the model just from the descriptions.
- In analysis models, the stream description should explain the use of
- input or output multipliers. This it typically a significant part of any model
- .
- All items in PhixFlow have a description property. We recommend you add a description to any item you create.
Naming conventions
Attribute names should be in camel case starting with an Upper Case Letter i.e. upper case letter for every "sub-word". E.g. MainCompanyName
The names of all local variables (variables start with a $ character) and pipe names should be in camel case i.e. lower case 1st letter and then an upper case letter for every "sub-word". E.g. $companyOldAddress, inPipe
...
- Ensure that attributes that represent the same thing in different streams have the same name. PhixFlow needs this when processing merges and for a union in a calculate stream.
- Formatting expressions
- Add comments to document your expression using:
- // for a single line comment
- /* ... */ to enclose multiline comments
- Include blank lines between statements
- Use spaces within expressions
- Indent sub-clauses by 4 spaces
- Add comments to document your expression using:
Naming Conventions
All user-defined variables must start with the $ character.
- To distinguish between $-variables that are:
- local use a lowercase first letter, for example
$percent
Local $-variables are only used in the current attribute. - global use an uppercase first letter, for example
$Percent
Global $-variables are used in the expressions for other stream attributes.
- local use a lowercase first letter, for example
- For multi-word names, use no spaces and camel case.
Multi-word stream attribute and pipe names should also be in camel case.
For | Example |
---|---|
stream attribute | MainCompanyName |
pipe | inPipe |
global $-variable | $CompanyLocationCounter |
local $-variable | $companyOldAddress |
Tip |
---|
Camel case uses an uppercase letter for the start of each sub-word, for example |
Layout for if()
if( condition, Statement 1 , // else Statement 2 )
...
Code Block |
---|
if( condition, |
...
Statement 1, |
...
// else |
...
Note that closing brackets should always line up with the start of the statement (see the do() and if() statements above)
Layout for switch()
switch( [ condition expression 1, Statement 1 ], [ condition expression 2, Statement 2 ], // default _NULL )
Note that the _NULL statement is currently required
Example Layout
Statement 2
) |
When there is more than one statement in an if() clause, wrap the statements in a do().
Code Block |
---|
// Example code layout
if( condition,
do(
Statement 1,
Statement 2,
.... Statement n
),
// else
Statement A
) |
To make it easier to see that statements are correctly bracketed, the closing bracket should always line up with the start of the statement.
Layout for switch()
Code Block |
---|
switch( [ condition expression 1, Statement 1 ], [ condition expression 2, Statement 2 ], // default _NULL ) |
The _NULL statement is required.