[AccessD] On Coding Standards

Bob Heygood bheygood at abestsystems.com
Tue Jul 8 11:50:20 CDT 2003


Hey to the group,
I like to name my variables for two reasons:
strXZZX tells me I am working with a string variable.
curListPrice tells what I am probably using the variable for.

JMTC,

Bob Heygood



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller
Sent: Tuesday, July 08, 2003 9:21 AM
To: AccessD
Subject: [AccessD] On Coding Standards


The following excerpt comes from
http://www.vbcity.com/forums/faq.asp?fid=30&cat=General&#TID30570. If the
subject interests you, I suggest you visit there. Here is a preview:

<article>
What are coding standards?

Coding Standards can relate to all areas of programming. In this FAQ we are
concerned with trying to convey information about an object by using a
naming convention. Naming your objects in a predefined way means you can
tell more about an object purely by the way it is named.
Lets take a standard Looping variable. If I call my variable 'X' it is not
obvious what it does :-

Code:For X = 0 to 10
  ...
Next X

If we change the name of 'X' it becomes obvious what it is doing :-

Code:For Index = 0 To 10
  ...
End Index

Although 'X' is quicker to type, it is unclear what it is doing. This
becomes more obvious when we have loops in loops:-

Code:For X=0 to 10
  For Z=0 to 100
    ...
  Next Z
Next X

For ParentIndex = 0 To 10
  For ChildIndex = 0 To 100
    ...
  End ChildIndex
End ParentIndex

The second version is a lot clearer and explains what is happening in the
loops purely by using 'Explanatory Names'. You may be tempted to save typing
by using Letters or short names. Resist this temptation and Cut and Paste
the name while using it.

</article>

This does not apply to Access, except in narrow areas like creation of types
or classes, but it's an interesting point nonetheless. Like many other
listers, I have habitually created all my variables with type-prefixes.
Given intellisense, this may be obsolete.

What do you think?

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list