ASP Best Practices

Next Topic

Object and Procedure Call Names

To distinguish object names and procedure calls from elements such as variables, begin each object name or procedure call with a verb. Use initial capitalization for each term within an object name or procedure call. Table A.1 suggests some naming conventions that could be used to name objects for some typical activities.

Table A.1   Naming Conventions for Objects and Procedures

Name

Function

Example

AddNew

Adds new records

Customer.AddNew

Update

Edits records

Customer.Update

Remove

Deletes records

Customer.Remove

Get

Returns row from database

Customer.GetNewest

List

Returns multiple rows

Customer.ListNew

To specify returns from methods that return information, use From and For with a method or function name.

Name

Function

Example

GetFor

Returns criteria-based row

Customer.GetForName

ListFor

Returns criteria-based multiple rows

Customer.ListForPeriod

Object Naming

Use initial capitalization for each term when naming objects, including built-in objects. Use descriptive names for objects, even though this requires more characters per name.

The following example conforms to this naming convention (cnn is the prefix for an ADO connection variable):

Set cnnSQL = Server.CreateObject("ADODB.Connection")
Set cnnSQLServer = Server.CreateObject("ADODB.Connection")

These names do not conform:

Set cnnS = Server.CreateObject("ADODB.Connection")
Set cnnsql = Server.CreateObject("ADODB.Connection")