Best practice methods and operations

The purpose of this document is to provide best practice guidelines when developing in Version 7.

The following rules are considered ‘best practice’ when developing methods and operations:

Methods and operations

Methods are stateful – Within a method, the current context is being ‘worked with’. For example, the properties within the class are already available.

Operations are stateless – Within an operation, the current content is being ‘read’. For example, the class data is not yet available and you must create the current context in which it operates.

Use meaningful names

You should create meaningful names (codes). Avoid using abbreviations and generic words. All codes must be created in English. For example: 'MYPROCESSCODE' instead of 'MYPROCCD'.

Storage

Methods/operations for a class/representation should be stored together. This makes it easier to maintain.

Avoid data duplication

A class can include child classes. When a class is used all its child classes are loaded and are online. You do not need to replicate information in the class and the child classes. It can be accessed if needed.

Check for parameters

The first step in any method or operation is to always check for any parameters. A method may be called in service mode; however, you need to check if what is expected is being passed.

Return a value

Any method or operation must return a status to show if it has been successful.

Deal with errors after a method call

After you call a method or operation you must check the return value. If any errors are returned you must deal with the error handling.

Free a Local instance

If you create an instance within a method or operation you must free the instance before you exit the method/operation.

Developing methods and operations best practice summary