13.4. Naming Objects

In the early days of programming, you were limited in the number of characters you could use to name objects and variables. Thus, you gave such meaningful names as x, cbw, or A1. Thanks to long filenames in 32-bit Windows, you are now able to identify objects using truly meaningful names, which in Access 2007 means 64 characters: plenty for most purposes. With such flexibility comes a dilemma: How do you name a class?

The name you assign to any database object will have an impact on its perceived purpose, and ultimately, its usability. It doesn't much matter whether it's a form, table, control, or class method; programmers will respond differently to it according to the name you give it. Ultimately it's up to you, but this section seeks to provide a few guidelines to help in the decision-making process.

13.4.1. What Does the Object Do?

Probably, the most important aspect of object naming is to describe what it is or what it does. For example, Access has many built-in objects that are, in my opinion, aptly named. These include the Database object, TableDef, Collection, Error, and so on. These names unambiguously describe the object to which they refer.

Other names describe the object's purpose, such as the Add, Count, and Remove methods; and let's not forget the OpenRecordset method. Fairly obvious what they do, wouldn't you say?

It is always good practice to keep the names as short as possible. The reason is that really long names are difficult to read and ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.