Reusable Logic

In System Modeler there are no restrictions on reusing logic.

User-defined methods allow logic routines to be packaged in a reusable form, for repeated use in ispecs, reports, and other classes. If several classes throughout the business segment repeat the same logic, you can move that logic out into a separate method that can be invoked from the methods of those classes. This is an advantage for maintenance, as changes to the logic only need to be made once.

If the logic updates database records of a class, you can move it to a method within that class, and give the method public visibility, so that it can be accessed from other classes in the model. You can then give the attributes it updates private visibility, so that they cannot be accessed except by the public method. If the logic only needs to be accessed from the inner members of its owning class, it can have private visibility, so that it cannot be accessed from outside the class. If it needs to be accessed by a class and its subclasses, you can make it a member of the superclass and give it protected visibility.

Since the logic is no longer part of the method that invokes it, you should be careful that it still behaves as required in a separate method.

For example, when an EndExit command is executed in a section of code within a framework method such as Main or Construct, the rest of the framework method logic is not executed. If the section containing the EndExit command is moved to a separate method and invoked from the framework method, the EndExit command exits the new method and also exits the calling method, right to the end of the framework method that called it. If this behavior is not required then use the “Return” command in place of EndExit.