Enterprise Systems

Identifier Naming Standards

Think of all identifiers as consisting of 4 parts: <Scope><Type><Descriptive Identifier><Usage>.

Of the 4 elements only the descriptive identifier is required by Oracle. However, the other elements serve to make the name better self-documenting code. At UNF, the first three should always be used. The usage element need only be used when appropriate.

Scope

Scope is the locality of reference within a package, procedure, or function.Knowing this is invaluable to the maintenance programmer. We keep this simple with only three designations: global (g), local (l), and parameter (p).

Examples:

.

Code

Scope

Example

g

Global

g_temp

l

Local

l_temp

p

Parameter

p_param

Type

The type portion of the name describes the identifier’s structure. There are simple types, such as constants and variables. In addition, there are more complex, aggregate types, such as records, tables, and cursors.

.

Type

Structure

c

Constant

v

Variable

e

Exception

cur

Cursor

rec

Record

tbl

Table

There are also special constructs that are available in PL/SQL. They are Type, Subtype and Cursor Variables.

.

Type

Structure

cvr

Cursor Variable

typ

Type

stp

Sub-type

Examples:

Notice that we combine the scope with the type as the first portion of the identifier name.

.

Example

Description

lc_tax_rate

Local constant

gv_counter

Global variable

lrec_spriden

Local record type

pv_student_id

Parameter variable

prow_sprtele

Parameter of ROWTYPE

Descriptive Identifier

The Descriptive Identifier is the most important part of a name. This can be a single word or a phrase. Deciding the lengths of names is always a trade off between length for documentation and brevity for typing purposes. So we want to be optimal. The name should pretty much tell the reader the purpose of the identifier. In most cases, the descriptive portion of the identifier should be comprised of a primary area such as student, address, or employee and a modifier that makes it more readable. The modifier(s) may precede and/or follow the primary area.

Examples:

mailing_addressstudent_last_nameemployee_number

Usage

In certain cases, a suffix should be used to qualify the identifier further to document the usage of the variable. For example, a suffix is used to denote the type of parameter, as in IN, OUT, or IN OUT or to indicate that the variable is a FOR .. LOOP index (which is not declared).