Initial Release
This is the first approximation of Caché ObjectScript guidelines we use for github.com/intersystems-ru projects. There are mandatory and recommended parts.
We do not plan to be very restrictive, but want be rather flexible enough and allow any reasonable style.
Here is the general advice: use common sense and try to be consistent wherever you write code.
If there is some style already established in the class or utility being modified then we recommend
to continue use that same style, than introducing yet another one, which may be more recommended
but which will be introducing some unnecessary inconsistency.
For Caché ObjectScript quick reference guide see here.
If (expression) {
Do ##class(Sample).%New(initexpresion)
For i=1:1:10 {
Write something, $ZVersion, !
}
}
or
if (expression) {
do ##class(Sample).%New(initexpresion)
for i=1:1:10 {
write something, $zversion, !
}
}
%Library
package)Set obj = ##class(Sample.Person).%New(initexpresion)
instead of
Set obj = ##class(Person).%New(initexpresion)
Sample.Person
, OpenFile
, LastIndex
, etc.), but smallCamelCase for local variables (e.g. startDate
, endDate
), but please be consistent and use local schema if it’s different than current recommendation.#dim
statement for declaration of local variables types, e.g. #dim array as %ArrayOfDataTypes = ##class(%ArrayOfDataTypes).%New()
do array.SetAt(id, "id")
#dim status As %Status = $$$OK
This will help editor to provide better auto-complete, and eventually will be used by static checker for type information extraction.
if (expression) {
do ..Method(args...)
set i = j + 1
} else {
while (condition) {
write arg1, arg2, !
}
}
Write 1, 2, 3
Do ..Method(arg1, arg2, argN)
For obvious reasons this recommendation not applies to arguments in $$$macro
-call, where such extra spaces will break final result.
#dim index As %Integer = 0
#dim countOfItems As %Integer = ..Count()
set j = k + 1
set iN = jN \ l