Showing posts with label Variable. Show all posts
Showing posts with label Variable. Show all posts

Naming convention used in naming variables

There is no hard rules in how you must name your variable but it is always a good practice to follow the naming convention to increase your program readability. Other programmers who work on your program can understand your code easier.

The commonly used naming convention in Foxpro programming is a two-letter prefix concatenated to the variable name.

The first letter will describe the scope of the variable, whether the variable scope is local, private, public or paramenter.
l - localp - private
g - public (global)
t - parameter

The second character denotes the type of variable.
c - character
y - currency
d - date
t - datetime
b - double
f - float
l - boolean
n - number
0 - object

Visual Foxpro use weak-typing

You do not need to define a variable before it being used. You just need to assign a value to a variable and the variable's type will change according to the value assigned to the variable. Not only that, you can change variable type by simply assign a value of different type to the variable and the variable type will change accordingly. I personally don't like this kind of weak-typing. It make the code very difficult to debug when error occurs.