Rules and Standards

CAA V5 C++ Naming Rules

Standard names for public CAA V5 C++ entities
Technical Article

Abstract

As 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.


General Principles

The following general principles have been established when choosing rules for CAA V5 names:

  1. Brand-based prefixes. A prefix [1] is used for most entities that may collide with other entities of the same nature, but developed outside the Dassault Systèmes (DS) Group. It denotes the DS origin of the entity. Other entity suppliers, and in particular CAA partners, are expected not to begin their names with DS reserved prefixes. Prefixes are based on DS brandnames, because of their perennity: CAT for CATIA, VPM and ENOV for ENOVIA, DNB for DELMIA)
  2. Aliases for frameworks. All frameworks (FW) are assigned a short 3-letter alias with first letter capitalized (e.g. CATDialog-> Dlg) [2]. This alias is used as a shortcut for the framework name for building other framework related names. It is referred to as <FWAlias> in the remaining of this document. Framework aliases will be defined in the framework's identity card. Trigrams are typically used to name entities that are associated to frameworks (e.g., modules). Since all modules from all frameworks are merged at runtime into common repositories (e.g., RuntimeView), trigrams provide a means of avoiding conflicts. For a given framework FW, the same trigram applies to the framework and to its associated FW.tst and FW.edu frameworks.
  3. English. Names are based on english/american words.

[Top]

Global Rule

Entity Name Entity Nature Naming Rule Metrics
1-All All <prefix><EntityName>
  • Name length should not exceed 27 characters
  • Names are composed using [A-Z][a-z][0-9] symbol range. Other symbols (such as \, -, /, ; _and the like) are forbidden
Nb of deviations / Nb of entities

[Top]

Entities Associated with a Directory

The entity and the directory that contain it must have the same name.

Entity Name Entity Nature Directory Naming Rule Notes Metrics
2-Code Framework Physical grouping of classes, interfaces, macros, functions dedicated to some specific task or domain. <prefix><FWName> Nb of deviations / Nb of entities
3-Test Framework Physical grouping of classes, interfaces, macros, functions dedicated to some specific task or domain. <prefix><FWName>.tst <prefix><FWName>.tst contain test material for code contained in the code FW. Nb of deviations / Nb of entities
4-CAA Frameworks Special kinds of frameworks that contain sample code and documentation that is intended for delivery to final customer as CAA products CAA<FrameworkName>.edu
CAA<FrameworkName>Doc.edu
CAA<FrameworkName>.tst
CAA<FWName>.edu contains only sample CAA Code (*.m modules).
CAA<FWName>Doc.edu contains only CAA Documentation (*.doc modules).
CAA<FWName>.tst contain test material for code contained in sample code FW.
Nb of deviations / Nb of entities
5-Code Module Physical grouping of interrelated objects within a framework, which defines the unit of code loading into main memory. <prefix><FWAlias><ModuleName>.m Modules should retain their FW name to avoid collisions when they are all mixed together in a single directory of the run time view. Nb of deviations / Nb of entities
6-Code Module in test FW Physical grouping of interrelated objects within a framework, which defines the unit of code loading into main memory. Used for testing the code delivered by a FW <prefix><FWAlias><Tst><ModuleName>.m Additional <Tst> allows same FW alias to be used between FW and associated FW.tst, without risk of duplicate names. Nb of deviations / Nb of entities
7-Code Module in education FW Same as code module, but within a CAA code framework. CAA<FWAlias><Edu><ModuleName>.m Additional <Edu> allows the same FW alias to be used between FW and the associated FW.edu, without risk of duplicate names. Nb of deviations / Nb of entities
8-Code main module Utility code module, unique to a FW, that act as the union of all the FW's modules when link editing other FWs modules. <prefix><FWName>.m Clients wishing to link edit with any module of the target FW do not have to know about each module name while retaining the benefits of FW modularity. Nb of deviations / Nb of entities
9-Doc Module in education FW Logical grouping of related documents about a CAA framework. CAA<FWAlias>TechArticles.doc
CAA<FWAlias>UseCases.doc
CAA<FWAlias>QuickRefs.doc
CAA<FWAlias>Base.doc
These modules are standard for those Fw.
TechArticles contain articles not linked to a particular piece of delivered code.
UseCases support some delivered code (in a CAAxxx.edu associated FW)
QuickRefs are for special articles that are presented as "catalogs" of resources for the Fw
Base is for the rest of articles, mainly navigation articles.
Nb of deviations / Nb of entities

[Top]

C++ Entities Associated with a File

A file, or a pair of files, must be dedicated to the following entities, that must have the same name than the files:

Entity Name Entity Nature Entity and File Naming Rule Notes Metrics
10-Simple Classes Standard C++ objects. Class: <prefix><FWAlias><ClassName>
File: <prefix><FWAlias><ClassName>.h
File: <prefix><FWAlias><ClassName>.cpp
A class named CATDlgBox must be declared in a file named CATDlgBox.h and implemented in a file named CATDlgBox.cpp. Only one class definition per file pair is allowed. Nb of deviations / Nb of entities
11-Extension Classes Special implementation classes that extent another class or a late type. Class: <prefix>E<FWAlias><ClassName>
File: <prefix>E<FWAlias><ClassName>.h
File: <prefix>E<FWAlias><ClassName>.cpp
<ClassName> is free, but it is recommended to use there the name of the extended class, as the extension actually belongs to the same 'logical' class. In case of several classes extending the same base class, it is recommended to use an integer number following <ClassName> to distinguish them. Nb of deviations / Nb of entities
12-Interfaces Object Modeler special classes that model an abstract behaviour that many classes may implement. Interface: <prefix>I<FWAlias><InterfaceName>
File: <prefix>I<FWAlias><InterfaceName>.h
File: <prefix>I<FWAlias><InterfaceName>.cpp
If the first letter in a framework alias is a I, then both I's should appear, as in CATIIxxIdentifiable. Nb of deviations / Nb of entities
13-Automation Interfaces Special type of interfaces that allows CATIA/ENOVIA/... programmation from scripting environments. Interface: <prefix>IA<FWAlias><InterfaceName>
File: <prefix>IA<FWAlias><InterfaceName>.idl
File: <prefix>IA<FWAlias><InterfaceName>.h
File: <prefix>IA<FWAlias><InterfaceName>.cpp
Nb of deviations / Nb of entities
14-Interface Dictionaries File containing a correspondence table between implementation classes or late types and the interfaces they implement. File: <prefix><FWName>.dico for CAA customers
File: <prefix><FWName>.dic for DS
One given framework must include only one interface dictionary. Nb of deviations / Nb of entities
15-Factory Dictionaries File containing a correspondence table between a class, and the factory interface that creates it. File: <prefix><FWName>.fact One given framework must include only one factory dictionary. Nb of deviations / Nb of entities
16-Global Functions and Variables C++ functions defined outside any class Function/variable: <prefix><FWAlias><FunctionName>
File: <prefix><FWAlias><FunctionName>.h
File: <prefix><FWAlias><FunctionName>.cpp
It is strongly advised to embody such function within an object as static functions, thus taking benefit from the scoping (::) operator. Nb of deviations / Nb of entities
17-Enumerated Types Programmer-defined type with value limited to a predefined list of named items. Type: <prefix><FWAlias><EnumName>
Value: <prefix><FWAlias><EnumItemName>
File: <prefix><FWAlias><EnumName>.h
In case of an enum with class scope, do not include the leading <prefix> to enum items, since the risk of name collision do not exist in that case. Nb of deviations / Nb of entities
18-Macros Piece of C++ code that is referenced by name is some other code and expanded by compiler at buildl time. Macro: <prefix><FWAlias><MacroName>
File: <prefix><FWAlias><MacroName>.h
Nb of deviations / Nb of entities
19-Typedef C++ alias that defines a name as a substitute for another name Same as substituted name A substitute name for something whose name begins by CAT, CATI, CATIA etc. should also begin with CAT, CATI, CATIA etc. Nb of deviations / Nb of entities
20-NLS resources File containing texts used as resources by code, and subject to translation in foreign language File: <prefix><FWAlias>Name.CATNls Error messages, dialog box names and labels, and prompts are typical NLS resources. Nb of deviations / Nb of entities
21-Resource catalogs Files containing non translatable resources File: <prefix><FWAlias>Name.CATRsc Icons are typical resources contained in a resource catalog Nb of deviations / Nb of entities
22-Feature catalogs File containing predefined feature definitions. File: <prefix><FWAlias><CatalogName>.CATFct for CAA customers
File: <prefix><FWAlias><CatalogName>.feat for DS
Nb of deviations / Nb of entities

[Top]

Language-independent Entities Associated with a File

Entity Name Entity Nature Entity and File Naming Rule Notes Metrics
23-Icon files File containing the graphical definition of an icon. File: <prefix><FWAlias><IconName>.<ext> <ext> refers to the standard file extension corresponding to the graphical format used (e.g. .bmp) . Nb of deviations / Nb of entities
24-Setting File File containing configuration information to save between two sessions File: <prefix><Name>.CATSettings Nb of deviations / Nb of entities

[Top]

User Interface Entities

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]

Other Entities

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:
  • The i prefix for input parameters
  • The o prefix for output parameters
  • The io prefix for input/output parameters
Refer to the CAA V5 C++ coding rules [2] Nb of deviations / Nb of entities

[Top]

Naming Variables Within C++ Code

Rules described in this section are 'best practices' for V5 code and mandatory for CAA code.

General Rules

Hungarian Notation

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]

Naming Interface Pointers

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:

  1. Choose a (short) identifier to refer to the implementation (e.g. Doc for a document) as a root name
  2. Forge a derived name around this root name when you manipulate this implementation through an interface pointer, by using the following pattern pi<InterfaceName>On<RootName>. Interface name is obtained by removing the <prefix>I prefix from its class name. For instance, piInitOnDoc and piPersistentOnDoc are two interface pointers (pi) by which a document implementation referred to as Doc is manipulated through interfaces of type CATIInit (Init) and CATIPersistent (Persistent) respectively.

[Top]


References

[1] CAA V5 Naming Rules
[2] Trigrams for Frameworks
[3] CAA V5 C++ Coding Rules
[Top]

History

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.