Many development
One rather simple convention is to use
lowercase_letters_with_underscores
for
Private m_picCanvas As PictureBox
Routine
Many developers carry these rules a bit further and add type prefix abbreviations to all variables, not just objects. For example, this statement declares an integer variable:
Dim iNumEmployees As Integer
If you apply these rules
mlngNumEmployees = intNumAbsent + intNumPresent
Some developers extend the rules to cover all programming objects, including functions and subroutines. For example, a global function that returns a string might be named gstrGetWebmasterName .
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}Generally, this scope and type information is more important the farther you are from a variable’s declaration. If you declare a variable inside a subroutine, a developer can usually remember the variable’s data type. If there is any doubt, it’s easy to scroll up and review the variable’s declaration.
In contrast, if a variable is declared globally in an obscure code module that developers rarely need to read, a programmer may have trouble remembering the variable’s scope and data type. In that case, using prefixes to help the developers’ memory can be important.
No matter which convention you use, the most important piece of a name is the descriptive part. The
Building an all-encompassing naming convention that defines abbreviations for every conceivable type of data, control, object, database component, menu, constant, and routine name takes a lot of time and more space than it’s worth in a book such as this. For an article that describes the conventions used by Microsoft Consulting Services, go to http://support.microsoft.com/default.aspx?scid=kb;en-us;110264. It explains everything, including data type abbreviations, making the first part of a function name contain a verb ( GetUserName rather than UserName ), and commenting conventions.
Naming and coding conventions make it easier for other programmers to read your code. Look over the Microsoft Consulting Services conventions or search the Web for others. Select the features that you think make the most sense and ignore the others. It’s more important that you write consistent code than that you follow a particular set of rules.