Can a class refer to a global in a different namespace?
Some of our interfaces use globals for lookups, but we are currently looking at putting a groups of (document) interfaces in a separate production with a shared ‘Default Database for Routines’ to reduce code duplication.
We understand we could simply place these globals in the %SYS namespace so they can be accessed from all namespaces.
The manual seems to imply that using %SYS Namespace (CACHESYS database) to store globals is accepted practice, and establishes a strict naming convention to ensure globals are not overwritten.
Further down the same page (link below), 'percent globals' are introduced;
Any global whose name starts with a caret and a percent sign (^%). These globals are generally referred to as percent globals. Note that via global mappings or subscript level mappings, it is possible to change where percent globals are stored, but that has no effect on their visibility. Percent globals are always visible in all namespaces.
Should we be using percent globals or %SYS/CACHESYS globals to store the global we want accessible between namespaces? Can I explicitly address a global in another namespace/database?
--
System-Supplied Namespaces
- %SYS — This namespace provides access to code that should not be available in all namespaces — code that manipulates security elements, the server configuration, and so on.For this namespace, the default routine database and default global database is CACHESYS. If you follow certain naming conventions, you can create your own code and globals in this namespace and store it in that database. See the next section.
- DOCBOOK — The DocBook application uses this namespace.
- Go to the %SYS namespace and create the item. For this namespace, the default routine database and default global database are both CACHESYS. Use the following naming conventions to prevent your items from being affected by the upgrade installation:
- In any namespace, create items with the following names:Because of the standard mappings in any namespace, these items are written to CACHESYS.