· Jan 7, 2018 1m read

Distributing Library Packages: Percent (%) classes vs %ALL namespace

Hi, Community!

Someday you find yourself having a wonderful class package which can be helpful in several projects. So it is a library package.

How to make the classes available for different namespaces in Caché? There are two ways (at least two ways familiar to me):

1. Start the name of the package with %, like %FantasticLib.SuperClass. Wrong way.

If you do that the class would be placed in %SYS and would be available in other namespaces.

This is wrong because of the two reasons:

1. The class will be wiped out with the next Caché update (as all the %SYS Namespace).

2. InterSystems can introduce its own %FantasticLib package.

3. You need to turn off 'read-only' flag on CACHELIB database to install the % class in it which reduces the security level of the system and makes the installation more complicated.

2. Name it without leading '%' like UsefulLibrary.Class and map it to %All namespace. Right way!

All the packages mapped to %ALL are visible in all the Namespaces (with one exception of "SAMPLES"). Documentation.

Yes, it needs one extra step in installation but you can import the library class in any "garbage" namespace like "USER" or to a separate DATABASE/NAMESPACE if the library is large and map the package in %ALL.

And yes, it's a pretty "Сap's" post, but I still meet examples of the %Lib approach, so hope it can be helpful.

Discussion (8)2
Log in or sign up to continue