Adopting a common, shared, standard layout style for all the scripts that are written expressions, scripts and macros makes it easier to "read" the scripts them and quickly understand what they are doing. In general PhixFlow ignores all spacing around the functional elements however spacing and layout makes the meaning much clearer for human readers!
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. Anybody looking at a model will first look at the descriptions of the elements. They should be able to discern the flow and the high level logic of the model just from the descriptions. Any use of Input or Output Multipliers should be noted in the stream description (as this it typically a significant part of any model).
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 for "global" variables (variables start with a $ character) i.e. variables which have a scope beyond the current expression and are used in subsequent expressions. Global variables should have an upper case first letter e.g. $CompanyLocationCounter.
Layout for if()
if( condition, Statement 1 , // else Statement 2 )
...
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
Code Block |
---|
// Example code layout if( condition, do( Statement 1, Statement 2, .... Statement n ), // else Statement A ) |
...