Good scripting practices - ObjectVision/GeoDMS GitHub Wiki
When formatting a DMS file, it is both convenient and good practice to follow a consistent style. To achieve this, we propose a few ground rules. These are listed below, followed by an example.
- Use consistent indentation and spacing.
- After the first letter/word/text element, use spaces (not tabs) for alignment.
- Align attributes and parameters vertically to improve readability.
- Align
:=operators so they form a clean vertical column. - After the domain (inside brackets), add only one space before the
:=. - After defining a container or unit, place a newline, then the
{on its own line, followed by the attributes on indented lines. - After the last attribute/parameter/container/unit, close with a
}using the same indentation as the opening{. - using a for_each statement, place the
:=after the container name. Then start a new line withfor_each_nedv(, listing each argument on a separate line, starting each with a comma.
- If part of the path in an item reference (in a calculation rule or as a domain or values unit) is not needed, omit that part. Relative paths are easier to maintain when modelling components are relocated or reused.
- Define and properly name a helper container/unit and refer to that instead to clarify intent and readability when
- a long path is used multiple times,
- a sub-expression is used multiple times in one or several calculation rules,
- using a relation multiple times, define it once and reference it rather than repeating it,
- a calculation rule contains many sub-expressions; consider replacing parts with a separately defined and named item.
- When using string comparison, it can be wise to use the lowercase operator around both arguments. That way, if something changes in the cases of the string, the comparison won't be affected.
Also, make sure to follow the naming conventions.
Examples:
unit<uint32> SomeUnit := SomeOtherUnit
{
attribute<rdc_meter> geometry (poly) := SomeOtherUnit/geometry;
attribute<string> name := SomeOtherUnit/name;
attribute<bool> IsHard := SomeOtherUnit/IsHard;
attribute<.> per_rdc_25m := poly2grid(geometry, rdc_25m);
attribute<bool> IsHard_25m := IsHard[per_rdc_25m];
}
container Zichtjaren :=
for_each_ne(
Time/Zichtjaar/name
,'Templates/Allocatie/Zichtjaar_T('
+quote(Time/Zichtjaar/name)+
','+Time/Zichtjaar/PrevState+
',Impl'
')'
), Descr = "Via dit template wordt het daadwerkelijke allocatie proces per zichtjaar aangeroepen.";