Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoid space characters in any 'Name' - Why ?

Good/Bad Naming Practices

Avoid space characters in any 'Name' - Why ?

by  LittleSmudge  Posted    (Edited  )
By 'names of things' I mean any Access object that the database developer provides a name for.
Eg.
Table Names
Field Names
Query Names
Form Names
Control Names
Variable Names
Report Names
etc.. ..


Although it is perfectly legal to have space characters in names, just because it is legal does NOT make it good practice.

Spaces in object names should be avoided like the plague.

Reasons:-
1) the absence of spaces clearly identifies a complete object.

2) You need never type another [ or ] bracket again.
[ and ] brackets are only necessary to enclose object names that have spaces in them.

It is true that Access will sometimes add [ ] brackets in places like QBE grids, of its own accord ( you won't go through life not seeing them ), but YOU will never need to type them again.

3) - Probobly most importantly.
If you use a field name, control name or variable in VBA code then there is a facility, in Debug Mode, to see what the value that the field, control or variable contains.
In break mode, if you hover your mouse over a variable, a box ( very much like a windows tool-tip ) appears at the mouse point and displays the contents of the variable etc.
This is extremely useful for debugging.

If there is a space in the name of your field, control or variable name then this does NOT work at all.



So - how do you maintain readability whilst avoiding the user of the dreadful space character?

NOT the underline character - because in certain circumstances the underline can become obscured and make reading the code by eye very diffecult.

The standard solution is to make all text lower case and then capitalise the first letter of each word in the object name.
Eg
TheFirstEventDate

This formatting approach is called 'ProperCase'


For further study on the topic of naming conventions look for the term Hungarian Notation ( Type "Hungarian Notation" into your favourite search engine and dig through the hundreds of links. - Or go to MicroSoft.Com and search there for a smaller number of ( better written? ) articles.)


'ope-that-'elps.

G LS
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top