Using Naming Conventions

Microsoft® Windows® 2000 Scripting Guide

In many organizations, names of assets whether they are buildings, computers, printers, or some other asset follow a standardized convention. For example, a computer name might consist of the name of the primary user followed by the user department. These conventions provide at least two advantages. First, the name alone gives you important information about the item; by itself, the computer name kenmeyer-finance tells you that this computer belongs to Ken Meyer in the Finance department. Second, this convention takes the guesswork out of naming new assets; when Pilar Ackerman in Accounting gets a new computer, coming up with a name for this computer requires very little effort.

Scripts are no different than these other assets; it can be advantageous to use standard, consistent, and meaningful names for scripts and for the variables, constants, functions, and procedures used in those scripts. These naming conventions help make your scripts easier to read, understand, and maintain.

Table 18.1 contains a brief overview of naming conventions in scripting. These conventions are discussed in more detail later in this chapter.

Table 18.1 Naming Conventions in Scripting

Item

Naming Convention

Example

Script file name

As short as practicable, with no spaces or special characters in the name. Capitalize the first letter of each word in the name.

CreateOU.vbs

Variable

Meaningful name that reflects the purpose of the variable and the data it stores. The first word in the name should be a prefix indicating the type of data stored in the variable. The prefix should begin with a lowercase letter, and all subsequent words should begin with an uppercase letter.

intNumberOfFileServers

Constant

All uppercase letters. Separate individual words with underscores, except for constants that are intrinsic to a language or to an automation object. In those cases, follow the naming convention used by the language or the automation object. For example, use VbTab rather than VB_TAB.

DOMAIN_NAME

Function or Procedure

Verb followed by the noun that the verb acts upon. Capitalize all words in the name.

DeleteBackupFiles