Rules and Standards |
CAA V5 C++ Naming RulesStandard names for public CAA V5 C++ entities |
Technical Article |
AbstractAs CAA V5 introduces a number of different programming entities, naming rules and conventions have been developed in order to avoid name collisions inside and outside the CAA environment, and to make things clearer for its developers. This article describes these naming rules for the C++ entities. |
The following general principles have been established when choosing rules for CAA V5 names:
[Top]
Entity Name | Entity Nature | Naming Rule | Metrics |
---|---|---|---|
1-All | All | <prefix><EntityName>
|
Nb of deviations / Nb of entities |
[Top]
The entity and the directory that contain it must have the same name.
[Top]
A file, or a pair of files, must be dedicated to the following entities, that must have the same name than the files:
[Top]
[Top]
These rules apply to the identifiers assigned to the user interface entities to ensure their uniqueness when you add a workbench or an add-in.
Entity Name | Entity Nature | Naming Rule | Notes | Metrics |
---|---|---|---|---|
25-Command Header | Proxy for a command in the application frame | <prefix><FWAlias><Name>Hdr | Nb of deviations / Nb of entities | |
26-Workshop | Set of workbenches associated with a document | <prefix><FWAlias><Name>Wks | Nb of deviations / Nb of entities | |
27-Workbench | A grouping of process-related commands | <prefix><FWAlias><Name>Wkb | Nb of deviations / Nb of entities | |
28-Toolbar | A (sub) grouping of related commands | <prefix><FWAlias><Name>Tlb | Nb of deviations / Nb of entities | |
29-Command Starter | A command starter | <prefix><FWAlias><Name>Str | Nb of deviations / Nb of entities | |
30-Separator | A separator between two commands in a menu or a toolbar | <prefix><FWAlias><Name>Sep | Nb of deviations / Nb of entities | |
31-Icon Box | A grouping of icons | <prefix><FWAlias><Name>Icb | Nb of deviations / Nb of entities | |
32-MenuBar | A list of menu accessors | <prefix><FWAlias><Name>Mbr | Nb of deviations / Nb of entities | |
33-Menu | A list of command accessible by name | <prefix><FWAlias><Name>Mnu | Nb of deviations / Nb of entities | |
34-SubMenu | A (sub) list of command accessible by name | <prefix><FWAlias><Name>Snu | Nb of deviations / Nb of entities |
[Top]
Entity Name | Entity Nature | Naming Rule | Notes | Metrics |
---|---|---|---|---|
35-Features and Late Types | Name that federates a number of interfaces as characteristic of a type. | <prefix><FWAlias><FeatureName> <prefix><FWAlias><LateTypeName> |
At run time, all features and late types are fetched from a virtual unique dictionary that concatenates all dictionary files from all frameworks. Therefore, two late types in two frameworks cannot bear the same name. | Nb of deviations / Nb of entities |
35b-Applicative Containers | Logical areas within a document that contain client features enriching supplied features. | <prefix><FWAlias>AppCont<ContainerName> | Applicative containers are accessed using their names in a session, therefore this name must be unique. | Nb of deviations / Nb of entities |
36-Data Members | Data associated to a class. | _<DataName> | The underscore helps to remember is source code that a
data member is being manipulated. Per CAA V5 coding rules, data member should never be assigned public (in the C++ sense) visibility. |
Nb of deviations / Nb of entities |
37-Method or Function Arguments | Arguments in function and method signatures. | Use:
|
Refer to the CAA V5 C++ coding rules [2] | Nb of deviations / Nb of entities |
[Top]
Rules described in this section are 'best practices' for V5 code and mandatory for CAA code.
CATBaseUnknown *pFirstItem, *pSecondItem;
It consist in putting a prefix in front of the name that reminds the reader of some aspect of the type of the variable (ex. is it an array?). The advantage is that it allows a better understanding of the valid operations that can apply to a certain type (ex. delete applies to a pointer, delete [] to an array).
Here is a table of standard hungarian prefixes defined for CAA V5:
Prefix | Means | Example |
p | pointer | CATBaseUnknown *pTarget; |
pp | pointer to pointer | void **ppTarget; |
pi | pointer to interface | CATISpecObject *piTargetFeature; |
sp | smart pointer || handler | CATISpecObject_var spTargetFeature; |
a | array | char *aPath; |
Note: when writing method signatures, the hungarian notation combines with the i, o, io prefixes that denotes the direction of information flow within arguments (f(CATISpecObject **ioppTargetFeature) denotes a pointer to a pointer to a feature that is used as input-output arguments -- i.e. after f() is run, the feature accessed through ioppTargetFeature might be a different one).
[Top]
Many interface pointers may be used in the same scope to manipulate one single implementation by different "behavioral handles". If those interface pointers bear very different names, figuring out that in fact one single object is being manipulated required a mental effort.
To avoid it, the following scheme is adopted:
[Top]
[1] | CAA V5 Naming Rules |
[2] | Trigrams for Frameworks |
[3] | CAA V5 C++ Coding Rules |
[Top] |
Version: 1.0 [Mar 2000] | Document created. |
Version: 1.1 [Oct 2000] | New brands prefix conventions; new global rule item. |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.