Naming Functions and Procedures

Microsoft® Windows® 2000 Scripting Guide

Functions and procedures are sections of code that carry out specific actions; in most cases, functions and procedures are employed because these actions must be carried out repeatedly during the running of the script. For example, you might have a script that needs to connect to the WMI service on several different computers. Instead of repeating that same code over and over again, you might place this code in a function or procedure. Each time you need to connect to the WMI service on a new computer, you simply call the function or procedure, passing along the name of the computer as a parameter.

Because functions and procedures carry out actions, the names given to these elements should begin with a verb that indicates the action to be performed. This verb should then be followed by a noun representing the object on which the action occurs. For example, CalculateMeritPay indicates the action that is taken (Calculate) and the object that is acted upon (MeritPay).

It is recommended that you use Pascal casing, in which each word begins with an uppercase letter, to help distinguish functions and procedures from variables and constants. Thus, use ConvertToKilograms rather than convertToKilograms.