The importance of naming conventions

As your databases grow in size and complexity, the need to establish a naming convention for the objects in your databases increases. As you already know, changes to the name of an object are not propagated throughout the database. Even with the Name AutoCorrect option turned on (Office Button?Access Options? Current Database?Name AutoCorrect Options), Access only corrects the most obvious name changes.

Changing the name of a table breaks virtually every query, form, and report that uses the information from that table. Your best defense is to adopt reasonable object names and use a naming convention early on as you begin building Access databases and to stick with the naming convention throughout the project.

Access imposes very few restrictions on the names assigned to database objects. Therefore, it is entirely possible to have two distinctly different objects (for instance, a form and a report, or a table and a macro) with the same name. (You can’t, however, have a table and a query with the same name, because tables and queries occupy the same namespace in the database.)

Although simple names like Contacts and Orders are adequate, as a database grows in size and complexity you may become confused about which object a particular name refers to. When working with Visual Basic for Applications (VBA), the programming language built into Access 2007, there must be no ambiguity or confusion between referenced objects. Having both a form and a report named Contacts might be confusing to you or your code.

The simplest naming convention is to prefix object names with a three- or four-character string indicating the type of object carrying the name. Using this convention, tables are prefixed with tbl and queries with qry. The prefix for forms, reports, macros, and modules are frm, rpt, mcr, and bas or mod, respectively.

In this book, most compound object names appear in mixed case: tblBookOrders, tblBookOrderDetails, and so on. Most people find mixed-case names easier to read and remember than names that appear in all-uppercase or all-lowercase characters (such as TBLBOOKORDERS or tblbookorderdetails).

Also, at times, we’ll use informal references for database objects. For instance, the formal name of the table containing contact information in the previous examples is tblContacts. An informal reference to this table might be “the contacts table.”

In most instances, your users never see the formal names of database objects. One of your challenges as an application developer is to provide a seamless user interface that hides all data-management and data-storage
entities that support the user interface. You can easily control the text that appears in the title bars and surfaces of the forms, reports, and other user interface components to hide the actual names of the data structures and interface constituents.

Take advantage of the long object names that Access permits to give your tables, queries, forms, and reports descriptive, informative names. There is no reason why you should confine a table name to ConInfo when ContactInformation is handled just as easily and is much easier to understand.

Descriptive names can be carried to an extreme, of course. There’s no point in naming a form frmUpdateContactInformation if frmUpdateInfo does just as well. Long names are more easily misspelled or misread than shorter names, so use your judgment.

Finally, although Access lets you use spaces in database object names, you should avoid spaces at all costs. Spaces do not add to readability and can cause major headaches, particularly when upsizing to client-server environments or using OLE automation with other applications. Even if you don’t anticipate extending your Access applications to client-server or incorporating OLE or DDE automation into your applications, get into the habit of not using spaces in object names.

Add to Technorati Favorites


// Related Posted - GOOGLE!

Loading



Related Websites
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>