How to naming
This document defines the naming conventions to use when performing standard or specific development tasks to avoid naming conflicts. Some of the rules stated below are classified as strict recommendations and must be followed rigorously. Others are suggestions that will be validated later.
Type | Recommendations |
---|---|
Strict | Dictionary naming |
Strict | Class and Representation naming |
Strict | Method naming |
Strict | Local menu naming |
Recommendation | Script naming |
Recommendation | Collection naming |
Recommendation | Menu items naming |
The code that identifies a dictionary element must follow these naming rules. This includes the following elements:
For these elements, the applicable rules are as follows:
Naming pattern | Use |
---|---|
A* | Supervisor elements. |
B* to T*, V* | Standard elements. |
U* | Table starting with U are usually reserved for temporary tables used during updates. |
W* | Generated elements. Those are only generated by an automatic process; modifying them manually is forbidden. |
X* | Add-on codes that might be developed outside of Sage. |
Y*, Z* | Specific elements developed outside of Sage. |
QLFarea_case | Test cases for automated tests. It is good practice to group the unit tests of the same area by having a common prefix. The naming rules are:
|
Note: By default, when using the meta data generation tool, the collection is called according to the pattern L* (previously C*). It is not recommended to keep this style of collection name because it is difficult, and therefore, makes the code less readable. It is recommended to rename a collection by giving it a clear and explicit name that does not conflict with other properties.
These rules are in addition to Naming rules for dictionary elements. They are applicable for standard development.
The main class that manages a table must have the exact same name as the table itself.
The cache class of a table must be named with the table abbreviation.
The desktop representation of a class must be named with the class name.
The mobile representation of a class must be named with the class name + the 'M' letter.
The tablet representation of a class must be named with the class name + the 'T' letter.
If an additional representation is added to the class, it must be named with the table name + a suffix that identifies its purpose.
Object | Name |
---|---|
Table | MYTABLE |
Main class | MYTABLE |
Cache class | MYT |
Main desktop representation | MYTABLE |
Main mobile representation | MYTABLEM |
Main tablet representation | MYTABLET |
Additional representation | MYTABLEAD1 |
If a variant class is added to the table, it must be named with the table name + a suffix that identifies the variant.
Object | Name |
---|---|
Table | MYTABLE |
Main class | MYTABLEVAR |
Main desktop representation | MYTABLEVAR |
Main mobile representation | MYTABLEVARM |
Main tablet representation | MYTABLEVART |
Additional representation | MYTABLEVARAD1 |
Classes that are not linked to a table must be named with a name that is different from an existing table name or table abbreviation. This means the class name cannot be one that already exists in the dictionary table.
It is important to distinguish between public methods that can be used by any developer using a class delivered in the standard, and private methods that are defined for internal use of the class implementation.
The private methods need to be prefixed by an underscore followed by a character that corresponds to the naming rule previously defined. For example:
The private methods are not documented and are subject to change without notice. To avoid their use by developers that don't follow the rules, it is recommended to implement the corresponding code in a separate script that is not supplied in the source.
MISCELLANEOUS TABLES | |
---|---|
Range | Use |
1000-1999 | Vertical developments |
4000-4999 | Addons |
6000-6999 | Specific developments |
8000-8999 | Localizations |
13000-13999 | Addons |
18000-29999 | Addons |
LOCAL MENUS | |
Range | Use |
160-164 | Messages for specific developments |
165-169 | Messages for vertical developments |
1000-1999 | Local menus for vertical developments |
4000-4999 | Addons |
5100-5199 | Messages for vertical developments |
5100-5199 | Local menus for vertical developments |
5200-5999 | Local menus for vertical developments |
6000-6199 | Messages for specific developments |
6200-6999 | Local menus for specific developments |
8000-8999 | Localizations |
13000-13999 | Addons |
18000-29999 | Addons |
There is no strict recommendation about the script organization except for the following rules:
A script storing a library of functions must follow the naming rules previously defined (prefix).
When functions are written for native version 7 functions, it is strongly recommended to write them in scripts that don't contain version 6 code. This will help in the future to deprecate the version 6 code.
We need to distinguish the scripts containing version 7 native code from the scripts containing version 6 code. We considered a recommendation to add _SYRA
to the end of the script name, but this might be awkward, and maybe we can find a better recommendation, such as, LIB_ means library, xxxx is an additional significant name. Further discussion is needed.
If we consider the TRTDEV V6 script that contains miscellaneous scripts related to currency controls
(currency is spelled "devise" in French), the recommendation is to have a name that contains CUR (LIBCUR_SYRA,
or CLIB_CUR, if we consider that C might be the abbreviation of core). Of course, this script will only contain code that is version 7 compliant.
If there is a subprogram that controls the currency, it would also be nice to rename it from "CONTDEV"
to "CONTCUR."
A good practice is to avoid Subprog when creating functions in libraries, and to use Funprog instead to simplify error handling. In a case where this is not relevant, we don't have an error class that would handle the error in a simple way. So then the normalization is:
AMSG
data type) that returns the error message if an error was raised.A script associated with a class is by default created with a name in 4 segments with an underscore between the second and third segments. This creates a name in the AB_CD format, where:
C
if the script is related to a class, and R
if the script is related to a representation.STD
for standard, SPE
for specific, VER
for vertical.For example, a vertical developer using the prefix XVE
for all his dictionary elements has a vertical script associated to the standard class BPCUSTOMER
. The recommended script name would be:
Because a script associated with a class could be huge for complex objects, or for a better code organization, it's useful to split this script into several subscripts.
Following the previous chapter the name will have 5 segments, what changes is the end of the name AB_CD_E
EVT
for class event managementPRO
for property event managementMPU
for public methods and operationsMPR
for private methods and operationsTYP
for the data type associated with the class managementGAT
for the class GATEWAY management (see Call between classic code and V7+ code).For example, the main script BPCUSTOMER_CSTD
will call subscripts as follow:
Caution: those subscripts have not to be defined as class scripts in the class dictionnary, they are called from the main one which act as a router.
BPCUSTOMER_CSTD_TYP
and BPCUSTOMER_CSTD_GAT
are not called from BPCUSTOMER_CSTD
. BPCUSTOMER_CSTD_TYP
will be linked to the data type in the data type dictionnary, and BPCUSTOMER_CSTD_GAT
will be called by the remote call API.
Example of what could be the BPCUSTOMER_CSTD routing:
$EVENT
Gosub EVENT From BPCUSTOMER_CSTD_EVT
Return
$PROPERTIES
Gosub PROPERTIES From BPCUSTOMER_CSTD_PRO
Return
$METHODS
If (left$([L]AMETHOD,1) = "_")
Gosub METHODS From BPCUSTOMER_CSTD_MPR
Else
Gosub METHODS From BPCUSTOMER_CSTD_MPU
Endif
Return
$OPERATIONS
If (left$([L]AOPERATION,1) = "_")
Gosub OPERATIONS From BPCUSTOMER_CSTD_MPR
Else
Gosub OPERATIONS From BPCUSTOMER_CSTD_MPU
Endif
Return
A collection is a property like any other. Using prefixes like C_ is strongly not recommended, for several reasons:
This doesn't mean that naming frequent collections is not valuable. For example, having a standard short name for addresses, or cost accounting segments can be a good idea. A simple name such as IADD
(invoice addresses), OADD
(order addresses), or CCE
(cost accounting) can be clear enough.
The menu items associated to classic pages have to follow the rule given by the menu profile naming tool. The other menu items follow the naming rules we already have for the other dictionary elements, described here.