9.3.7- Use a Variable Naming Convention (Consistently!)
by NT Community Manager.
|
| << 9.3.6- Convert Your Variants into the Requisite Subtypes | Chapter9 | 9.3.8- Try to Break your Code >> |
Use a Variable Naming Convention (Consistently!)
In Chapter 4 we discussed the many benefits of using a good naming convention to help us keep track of which variables contain which subtype of data, especially when we have lots of variables in a program. We recommended a specific naming convention (go back and check it in Chapter 4 , if you can't remember it). In this manner, you can tell at a glance whether you're using an integer, a string or date and can manipulate it in a consistent way. Our suggested convention was to use the first three letters of a variable's name to distinguish the subtype. The fourth letter of the variable was then typed in upper case, to indicate that this is where the actual variable name starts. For example:
blnBoolean
'where bln denotes Boolean in our convention, and Boolean is the
'variable name
intInteger
'int denotes an integer in our convention, and Integer is the
'variable name
One problem is that naming conventions are used inconsistently. Programmers often start out defining and naming all of their variables correctly – it is when a piece of a code has to be changed or updated that things often go awry. For example, a temporary variable (called something like test) is introduced and then, the next thing you know, that variable is being used to pass data as well. You might find variables that 'break' our suggested naming convention in this book – it's not deliberate, but this tip requires a lot of attention from the programmer and it is easy to miss something.
| << 9.3.6- Convert Your Variants into the Requisite Subtypes | Chapter9 | 9.3.8- Try to Break your Code >> |

RSS

