Skip to content

Naming Conventions

We recommend that you use Hungarian notation when naming identifiers in your DataFlex applications. Hungarian notation is a set of detailed guidelines for naming identifiers such as types and variables. The convention is widely used in many programming languages, especially in Windows programming.

The Goals of Notation

  • To identify global variables: One common programming problem is the misuse of global variables.

  • To identify class definitions: Naming conventions for classes serve two purposes: they explicitly identify an identifier as a class name, and they avoid naming clashes with objects and other variables or reserved words.

  • To identify constants: Named constants need to be identified so that you can tell whether you are assigning a variable a value from another variable or from a named constant.

  • To enhance readability

Base Types

Hungarian notation works by prefixing identifiers with standardized codes. Each prefix categorizes the identifier according to its type and use.

The first level of identifier prefixes identifies the base types. The base type identifies the fundamental type of identifier that you are naming (e.g., is it a class, object, constant, or variable). Hungarian notation prefixes each type of token to identify its base type as outlined in the following table:

Base Type Prefixes

Prefix Meaning
c Class
C_ Constant
g Global Variable
o Object
p Property
t Struct Type
Local Variables (no-prefix)

All the prefixes, except C_ for constants, are in lowercase and placed before the rest of the token name.

Note: The local variable base type does not use a prefix.

SubType

Subtypes go a step beyond the base type and describe the specific use of constants, global, and local variables.

SubType Prefixes

Prefix Meaning
b Boolean
d Date
h Handle
i Integer
n Number
r Real
s String
v Variant
ri RowId
Struct type variables (no prefix)

All the prefixes are in lowercase and placed before the rest of the token name but after the base type prefix.

Note: Struct type variables do not use a prefix.

Arrays

The naming convention for array variables is to prefix the variable as per the array's declared type, then append 's' to indicate a plural.

Examples of Hungarian Notation

define C_PI for 3.14156  // A constant.
Integer giCount          // A global Integer variable.
String  gsName          // A global String variable.
Struct tAddress         // A Struct Type
Integer iStreetNumber   // An Integer Struct Member
String  sStreetName     // A String Struct Member
String  sCity
End_Struct
Class cSearchButton is a Button  // A Class
Procedure Construct_Object
    Forward Send Construct_Object
Property Integer piCount 0  // An integer property.
Property String  psName ""   // A string property.
End_Procedure
Procedure OnClick
    Boolean   bFound          // A local Boolean variable.
    Integer   iCount          // A local Integer variable.
    String[10] sNames        // A local string array
    // Note, Struct Variables do not use notation
    tAddress MyAddress
End_Procedure
End_Class
Object oSearchButton is a cSearchButton  // An Object
End_Object