Naming conventions

bnickelsen

Registered User.
Local time
Today, 04:32
Joined
Jan 6, 2005
Messages
31
When I started using Access excel had been my closest app. to a database.

My first attempts to build a database failed because I tried to build the database like sets of excel sheets.

Any ways I then discovered Normalization, that helped a lot.
Now I am wondering about naming rules.

I have seen a few examples like:
ThisTableName,
strThisFieldName,
this_field_name,

Is there one standard or method or is this just user preference?
 
Naming Conventions.

I typically name my databases dbdatabasename - i.e. dbStock

The accepted prefixes are tbl (table), qry (query), frm (form), rpt (report), mcr (macro), and bas (modules). I don't know if dap is used for data access pages - never used them.

Next up, objects within these objects.

I've seen people use fld for each field which, in my opinion, is overkill. I will use fld if I'm creating a DAO field in VBA.

so, form objects:

txt - textbox
cbo - combobox
cmd - command button
lbl - label
lst - listbox
fra - option group
chk - checkbox
shp - shape/rectangle
tgl - toggle button
opt - radio button
img - image
tab - tab control
ctl - for ActiveX controls i.e. ctlCalender, ctlDatePicker

Moving on, variables and objects

byt - byte
boo - boolean
int - integer
lng - long integer
sng - single
dbl - double
dte - date/time
cur - currency
obj - object
var - variant
db - database object
rs - recordset object
cn - connection object
tdf - tabledef
qdf - querydef
col - collection
fso - file system object
mnu - menu object

There's loads more but that should do for now.
 
I think I can Figure out most of the rest.

Thank you
 
There are multiple standards out there. SJ gave you one that is common. Others exist. SJ tells you about prefixes, and that can help for some things, but there is another side of the same exact issue.

A far more important consideration is that you first must make up object names that have meaning in the particular context. Like, if you are dealing with parts having an SKU number, call it SKU or SKUNum or something like that. Don't call it GEORGE. This is referred to as having "mnemonic" value from the old minor Greek goddess Mnemosyne (I think I got that right).

Next, you had better get used to either having very long names or very cryptic ones. But choose one or the other, TRY to be consistent, and totally avoid names that have no meaning whatever. Like, Label11, TextBox12, ...

Now, there's a GOTCHA waiting here on the above topic. If you use a wizard to create something, DON'T TRUST IT TO USE MEANINGFUL NAMES. It won't. Go back and fix the names ASAP so you don't have to guess at which label goes with which active control.

After that, if there is any chance that at a future time your DB might have to migrate to something a smidge larger (like MySQL or SQL Server :eek: ), NEVER EVER use _ (underscore) or blanks in object names at any level - whether in tables, fields, or other places. Just break that bad habit BEFORE it starts. Even if you never migrate, it was a bad habit that you should never get into.

A really big GOTCHA that often comes up to tweak your nose and give you a headache is use of a reserved word as a variable or object name. Find the list of reserved words. Print out the list. Avoid using those names for any purpose other than that for which they were reserved. Save yourself so much grief that you won't believe how bad it can get.

Now, I'll get even wilder. Who gives a flyin' fiddle-dee-dee about what you named anything? Six months from now, you'll have forgotten your names anyway because you were totally immersed in something else. We are creatures of habit. We focus on problems of the day. So to fight this (very natural) tendency, make lists. Use paper printouts to hold your lists. Remember, paper has a better memory than people. Also better in some ways than computers, since you can't pull the plug on a piece of paper and have it do a memory dump. Use the built-in documenter (Tools >> Analyze >> Documenter) every so often. Make updates of your object lists at every level for every object you create.

When you find yourself writing anything, make HEAVY use of any available documentation fields, comment fields, tool-tip fields, etc, as mnemonic devices to help you remember what something is or means. In VBA code, you need to learn how to COMMENT things. In other items, like field defs in a table, you can comment field usage in the DESCRIPTION column. You can add information in object properties. On category panes (tables, queries, forms, etc....) you can right-click on any object and can then enter a description of it. Get used to doing that. The cost is trivial compared to the headaches you will head off later.
 
Hey Doc, I'm looking for you

Hate to post jack BUT Doc, if you see this jump over to The Watercooler and look for a thread I started for you asking for some New Orleans info.
 
Leszynski Naming Convention

Rather than re-invent the wheel, there already is a consensus naming convention. Follow this link to check it out:

http://www.acc-technology.com/namconv.htm

The link also hawks some re-naming software designed to do the renaming for you. I can't comment on the software, because I've never tried it.

But I do use this convention. After a while it becomes second nature, and then it's so much easier to remember what you named something. I just wish Access would do much of the leg work for you by making their default names follow this convention, rather than using all that underscore crap.

-Nelson
 
A far more important consideration is that you first must make up object names that have meaning in the particular context. Like, if you are dealing with parts having an SKU number, call it SKU or SKUNum or something like that. Don't call it GEORGE. This is referred to as having "mnemonic" value from the old minor Greek goddess Mnemosyne (I think I got that right).
"This Titaness of beautiful hair discovered the uses of the power of reason, and gave a designation to every object, which is of the utmost importance, since without names very little could be expressed, and mortals would not be able to hold conversations with each other." Link

and speaking of prefixes,

where the heck did bas come from to describe a module?

and, fsub instead of sfrm drives me a bit batty. i can see fsub being useful if you want to keep your fs together, but other than than it's incredibly counter-intuitive, no?
 
wazz said:
where the heck did bas come from to describe a module?

From BASIC, the language modules are written in. ;)
 

Users who are viewing this thread

Back
Top Bottom