Scripting Style

Adopting a common, shared, standard layout for all the scripts that are written makes it easier to "read" the scripts and quickly understand what they are doing. In general CenterView 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 subclauses 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 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

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 when a statement in an if() clause is more than 1 line, wrap them in a do() e.g.:

if( condition, do ( Statement 1, Statement 2, .... Statement n ) , // else Statement A )

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