The Fundamentals of the Hungarian Convention
The Hungarian convention has a very straightforward design. It dictates that a name may contain up to five parts, and that the parts are combined in the order of prefix(es), tag, base name, qualifier, and suffix:
□ A prefix precedes a tag to provide clarification. It can describe one or more important properties with one or two lowercase characters.
□ A tag is considered by some to be the critical, non-optional element. A tag should be unique and easily differentiated from similarly named tags. A tag is typically three (occasionally four) lowercase characters that identify what the object is — a table, form, or text box, for example. The tag is usually a mnemonic abbreviation, such as tbl, frm, and txt or the first letter of each word from multiword items. Exceptions are often due to the tag already being assigned for a different purpose, adopting a tag from another program, and, of course, that it isn't always easy to create an intuitive three-letter abbreviation.
□ The base name is a descriptive name that defines the particular object. This could be the layman's term used to concisely identify the subject. Use proper case and be brief but clear.
□ A qualifier is an extension that indicates how the object is being used. Qualifiers should be title case and as short as practical, without sacrificing comprehension. For example, the qualifier Avg may be added to a query name to indicate that the query calculated the qryStudentGradeAvg (or qsumStudentGradeAvg).
□ A suffix is rarely needed. Its purpose is to differentiate object names that could otherwise be identical. The suffix is written in title case or as a number and should be as short as practical. For example, a series of queries that calculate the average grade for each grade (see the need to make a distinction?) could be named qryStudentGradeAvg4, qryStudentGradeAvg5, and qryStudentGradeAvg6, indicating the average for the fourth grade, the fifth grade, and the sixth grade class, respectively. And, although many developers avoid using the underscore, some developers like to separate the suffix by using one, as in qryStudentGradeAvg_4.
Although it isn't necessary for an object name to contain all of the parts, nearly every name will contain a tag and a base name. For example, here's the name for a table: tblStudent. You can quickly see that it conforms to the rules — there are no spaces, the tag is all lowercase, and the base name is title case. That is a fairly universally accepted format. Remember, object names should never include special characters or spaces. Other guidelines that you may want to follow are covered in the "Rules for Creating Names — Adding the Personal Touch" section later in this appendix.
The flag is the optional sixth part to a name. A flag affects where an object appears in lists and is effective for grouping items at the beginning or the end of a list. The following table describes common flags.
|
Flag |
Description |
|
_ (underscore) |
Causes the item to be listed before numbers and letters. Often used for items under development. |
|
zh |
Indicates a system object used for development and maintenance, but it is a hidden object. |
|
zs |
Indicates a system object used for development and maintenance but should not be seen by the end user, but not hidden. |
|
zt |
Indicates a temporary object that is created programmatically, such as a query built by code, and not preserved after it has been run. |
|
zz |
Denotes an object that you are no longer using and that is waiting to be deleted. |
Remember that object names should never include special characters or spaces.
Post a comment