Using a Local Variable Is Preferable to Using a Global Variable

It is recommended that you use a local variable where possible instead of a global variable for the following reasons:

  • A local variable helps you create modular code that is easier to debug and modify.

  • A local variable requires fewer resources.

  • It is easier for other developers to understand how you use a local variable in a single function than it is to understand how you use a global variable across an entire Siebel application.

  • If a subsequent development team encounters an object that you script with a global variable, then this team might not understand the use of the global variable. If the team uses this variable, then the team might introduce defects.

  • The scope of a global variable is too large to meet the business requirement and often results in a variable whose lifecycle is not clear.

Instead of using a global variable, it is recommended that you configure Siebel CRM to pass an object as a parameter to a function so that you can control the scope of the parameter. If you are considering using a global variable, then you must consider this usage carefully. If you use a global variable, then do so only rarely and document it thoroughly.