Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding Standards
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Coding Standards
Miscellaneous
Thread ID:
00115272
Message ID:
00115272
Views:
70
I was wondering about the coding standards we all use and whether it wouldn't be a good idea to compile a list of suggested coding standards that we might be able to share. I know that many frameworks enforce some standards... Codebook does to a degree. Still, I thought it might be interesting as well as instructive to open the topic for discussion.

Oh, and if y'all think it's a good idea, I will compile the list of suggestions we all accept into a word document which we could post here.

Just to get the discussion started, here are some standards that I always use.
Variable naming (comes from the Codebook)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o First character of variable name indicates scope as follows:
  L = Local
  G = Global (Public)
  P = Private
  T = Parameter (I never distinguish between private and local parameters because I only use Local parameters)

o Second character is the data type. In the rare instances where the data type is not known beforehand, use 'U'. Otherwise, use the data type character used by the TYPE() function (e.g. C = Character, T = DateTime, etc.)

o Rest of the name is something descriptive. Long variable names are OK but I try not to go overboard.

Field Naming Conventions
~~~~~~~~~~~~~~~~~~~~~~~~
Basically, do the same thing as done for variables but no scope character.

Other Heuristics
~~~~~~~~~~~~~~~~
o Don't abbreviate commands and functions in code (what you do in the command window is your business :))
o Indent programming structures with a tab.
o When I have a lot of assignments within an object structure, I use WITH/ENDWITH. It makes the code easier to read and is supposed to run slightly faster.
o Always assume that anything you write in code will be read by someone else. (If you're interested, there's a story behind this one).
o Command and Functions are always in CAPS.
o Variables are in mixed case. Usually, the first two characters are in lower case and the third character is in upper case (with further capitalization as appropriate). For example, goAPP, lnEmployeeNumber


Object Naming Conventions
~~~~~~~~~~~~~~~~~~~~~~~~~
o Use the conventions in the help file.
There are more but these are the ones that come to mind off the top of my head.

Again, I will keep track of the responses to this message to make a document out of it to post here on the UT.
Menachem Bazian, CPA
President
BC Consulting Services, Inc.
973-773-7276
Menachem@BazianCentral.com
Next
Reply
Map
View

Click here to load this message in the networking platform