STRUCTURING OBJECT NAMES

In LNC, object names are constructed by using the following syntax for Level One:

[prefix(es)] [tag] BaseName [Qualifier] [Suffix]

For Level Two, the syntax varies slightly:

[prefix(es)] tag [BaseName] [Qualifier] [Suffix]

The brackets indicate optional syntax elements (don't include the brackets in actual object names). Notice that, for Level One, the BaseName element is required and the tag is optional in some cases. At Level Two, the tag element is required, even though the BaseName isn't in some cases. These options are explained later in this appendix in the section “Rules for Base Names.”

Note

The case of each element in the syntax examples reflects its case in actual use. For example, the element tag is in lowercase because the tags themselves are always lowercase.


Table D.1 shows sample object names with these constructions.

Table D.1. Object Names Constructed in LNC Format
Object Name Prefix(es) Tag Base Name Qualifier Suffix
tblCust  tbl Cust   
qsumSalesPerfBest_WA q sum SalesPerf Best WA
plngRecNumMax p lng RecNum Max  
ialngPartNum ia lng PartNum   

What Is a Prefix?

A prefix is an identifier that precedes a tag and clarifies it narrowly. Prefixes describe one or more important properties of an object. For example, a Long variable that's public in scope (declared Public) has a prefix p, as in plngRecNumMax. Prefixes are one or two characters long and are lowercase. You can use multiple prefixes together on one object, as in ialngPartNum, where i and a are both prefixes.

What Is a Tag?

A tag is a character phrase placed against an object base name to characterize it. In object-oriented programming terms, the tag basically is an identifier for the class. At Level One, we could say that tags define an object's general class—for example, qry for a query of any type. At Level Two, the tag defines the specific class—for example, qdel for a delete query. Note that the word class here refers to a naming convention construction, not an object model construction. For example, there is only one Query (or QueryDef) class object in Access, and the data action (delete, update, and so on) is determined by its SQL statement, not its class. LNC prescribes several tags for this one Access class.

Tags are three or four characters long for readability and to allow for the hundreds of combinations necessary as the Microsoft Office object model grows over time. They're always to the left of the base name and lowercase, so that your eye reads past them to the beginning of the base name.

Tags are ideally created to mnemonically represent the word they abbreviate, such as frm for form. However, some tags may not seem fully mnemonic for two reasons. First, the perfect (that is, obvious) tag for a particular object may already be assigned to another object. Second, where common objects (objects with similar properties and usage) exist in multiple Microsoft applications, the tag for one may be used to represent similar objects in other products, even if the names are different. For example, an Access Rectangle object is almost identical in structure and purpose to a Visual Basic Shape object. Because our Visual Basic conventions have existed longer than our Access conventions, we used the Visual Basic Shape object tag, shp, to also represent Access's rectangles. Finally, there may not be such a thing as an obvious tag, so a suitable one may be chosen from a body of several reasonable candidates.

What Is a Base Name?

The base name is the starting point when you name a particular object—the name you would use anyway if you had no naming conventions. The LNC guidelines for creating base names are driven by a set of rules explained later in the section “Rules for Base Names.”

What Is a Qualifier?

A qualifier is an extension following the base name that provides context to the specific use of an object. Unlike prefixes, which detail properties of the object (for example, that the variable has public scope), qualifiers describe how the object is being used in a context. For example, plngRecNumMax is obviously the maximum record number in an application that also could have variables for the minimum (plngRecNumMin) and current (plngRecNumCur) record numbers. Qualifiers are short and written with mixed upper- and lowercase, using the list in Table D.2.

Table D.2. Standard Qualifiers
Qualifier Usage
Curr Current element of a set
Dest Destination
First First element of a set
Hold Hold a value for later reuse
Last Last element of a set
Max Maximum item in a set
Min Minimum item in a set
Next Next element of a set
New New instance or value
Old Prior instance or value
Prev Previous element of a set
Src Source
Temp Temporary value

What Is a Suffix?

Suffix elements provide specific information about the object and are used only as tie-breakers when more detail is required to differentiate object names that otherwise could legitimately be identical. This is the only element in the syntax where our naming conventions don't specify standardized values. You'll create suffix items as needed by your company, development team, or application. For example, a series of queries that summarized the best sales performance by state would need the state name in the object name to properly qualify it, as in qsumSalesPerfBest_AK. Placing the state name at the very end of the name as a suffix item allows the entire collection of related queries to sort together, like this:

qsumSalesmanPerfBest_AK
qsumSalesmanPerfBest_AL
...
qsumSalesmanPerfBest_WY

Tip

Because the suffix is the last piece of information on a name, it can be easier for the eye to find if it's delimited from the rest of the object name with an underscore character. Use of the underscore character is optional, not required.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.109.157