The $CASE function can be written without a default case, as in:

    set x = $case(someVar, "foo": val1, "bar": val2)

However, this means that if, in the above example, the value of x is neither "foo" nor "bar", the resulting value will be undefined.

On Unicode installations of Caché, it is possible to use letters in variable names which are not ASCII letters.

For instance, a program written in Caché could have a variable named validación.

ObjectScript allows local variables to have the same name as builtin commands, as in:

    set throw = 1

This is very confusing and should be avoided. It is highly recommended to change the variable name to something else.

It is customary to use the HANG command so that the debugger can attach to the running process when debugging code.

However, it frequently occurs that this extra statement, which is there only for debugging purposes, is not removed before the code is commited.

Please check that this usage of HANG is legitimate; if this is the case, mark this issue as a false positive.

ObjectScript allows to attach postconditionals to some commands; for instance:

    // Set the value only if condition c is true
    set:c x = 2

This is in fact equivalent to writing:

    if (c) {
        set x = 2
    }

This feature of the language may lead to shorter code overall; however, users unfamiliar with the language may have trouble understanding what this syntax means.

For understandability reasons, it is preferred to use an if statement instead.

The OPEN command has a very complicated syntax which is difficult to get right.

It is preferable to use classes from the %IO package instead which are much easier to use and provide the same functionality.

For instance, for opening a file, instead of using:

Given a property named, for instance, p in a class instance, ObjectScript automatically defines both getter and setter methods named, respectively, pGet() and pSet().

This means that the two following lines are equivalent:

    // Given an object instance o and a property p, write the value of p
    w o.p
    w o.pGet()

However, ObjectScript allows to override those methods. Consider the following:

The BREAK command is normally used in interactive code to suspend the execution of a program at a given point.

This means that it should never be used in non interactive code. You should check that this BREAK invocation is legitimate in this context.

Trap...

People coming from other languages where break exits a loop may be tempted to write, for instance:

ObjectScript allows to use macros as statement, as in:

    Method m()
    {
        $$$SOMETHING
    }

or even:

    Method m()
    {
        $$$SOMETHING(with, arguments)
    }

Here, SOMETHING is a macro. The problem is that a macro can expand to anything; for instance (for the argumentless version):

Starting with Caché 2010.1, InterSystems does not document the $ZUTIL function anymore. It is advised that uses of this function be replaced with alternatives.

Please see this URL for a list of replacements.

Pages