Chapter 4 -- Naming Conventions

[Previous] [Next]

Chapter 4

New objects and data types continue to emerge as Microsoft Visual Basic grows in complexity. Program code often references controls as well as variables , and in complex procedures it can be difficult to fully understand everything that is occurring in the code. How do you determine whether a particular statement references a variable or a control? Without some sort of convention to differentiate variables from controls, code is more difficult to read. For instance, can you tell exactly what is happening with this statement?

 TotalDue = LineItemTotal - Discount + TotalTax 

Without a way to distinguish variables of different data types from various objects, you can't tell what the statement is doing. Is TotalDue a variable or a text box? Or is it a label control? The same questions apply to the other items. If LineItemTotal is a variable, what type of variable is it? Currency? Single? Variant? To make code more self-documenting (always an important goal) and to reduce the chance of programming errors, you need an easy way to distinguish variables from controls and you need to make it easy to determine the exact data type of a variable or the exact type of a control.



Practical Standards for Microsoft Visual Basic
Practical Standards for Microsoft Visual Basic .NET (Pro-Developer)
ISBN: 0735613567
EAN: 2147483647
Year: 2000
Pages: 57

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net