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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable & Field Names?

Status
Not open for further replies.

SMCmtg

Programmer
Mar 27, 2000
90
0
0
US
Hi VFP7 experts: Need to ask a "basic" fundamental question, and request your feedback/thoughts on hundreds of field name and hundreds of variable names. . .
I started off 3 year ago writing/learning using field names like the book says, i.e. Lyes, Lno for logic fields, Clname, Cfname for Character fields etc. . .Variable names like vsomething. . .etc.
I thought I would remember all of them. . . but now after all the that time and changing several times somewhere along the way, I am now like a physican who can't read his own writing. . .and have to wade thru it!
I there a worksmarterandnotharder way to do this?
which would make it intutitive? or do I have oldtimer's diease or how do I eat an elephant. "One bite at a time?"

Feedback is appreciated.

 
I like
first letter of name to tell me the field type
then the table name or at least part of it
then an indicator of what the field holds

cEmployeeLastName Attitude is Everything
 
Since I don't like to type any more than necessary, I try to keep variable names as short as possible. I also think it is clearer to use the data type as the first character.

My best suggestion though is to be consistent.

Dave S.
 
As DSummZZ states, as many other programmers use, the Hungarian notation for variable naming is an widely accepted form of coding. It also helps "the next" programmer to understand your code, if ever need be.
Here an example of what I use.

Scope Characters
L Local
P Private
G Global (public)
T ParameTer
Type Characters
C Character
D Date
L Logical
N Numeric, Float, Double, Integer
O Object
T DateTime
U Undefined
Y Currency


 
Hi,

I do not use a first character to indicate a variable type. Visual FoxPro does not have strong variable typing, so the type a variable assume can depend on what value is being place into the variable. For example:

x = 1

At this point x is a numeric variable.

x = "Leland"

With the above statement Visual FoxPro happily changes variable x to a character type and there will be no error messages, etc. In a stronly typed language, like Visual Basic or C++, the variable are declared at the beginning of the program and cannot be recast.

Both methods have there pros and cons, but the only real way to be sure about a Visual FoxPro variable type is to examine it with something like a debuger to see how it is cast within a particular line of code.

The lose typing of Visual FoxPro variables can cause problem if the programmer accidentally changes a variable type, for example a numeric variable is changed to a string, and then he uses it in a program line that expect a different variable type. For example the following line will produce an error where x has accidentally been changed to a character type variable:

go x


Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
thanks for the review.

"c", "table","field"
all shortened up.
"cEmpLnam"

Some cleaning to do!

THX all for your suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top