Microsoft Office 2000/Visual Basic Programmer's Guide |
Some inexperienced developers feel that although formatting code may make it look "pretty," it is not really worth the time. However, properly formatting code has nothing to do with appearance and everything to do with how easy your code is to understand and maintain. The basic techniques used to format code are line breaks, white space, and indentation. In addition to making the code easier to read, these formatting techniques help document the code by showing the logic and flow of a procedure and by grouping logically related sections of code.
For examples of VBA and VBScript code that use the formatting techniques discussed in this section, see the code samples in the ODETools\V9\Samples\OPG\Samples\CH03 subfolder on the Office 2000 Developer CD-ROM.
Even developers of the most poorly written VBA code usually make some attempt at naming things consistently and adding comments and perhaps some white space where appropriate. But something very different is happening on the Web. It seems that there is no attempt to use naming conventions or formatting techniques to make script easier to understand and maintain; in fact, just the opposite seems to be happening. Perhaps it is the forgiving nature of an HTML page as a scripting environment. Perhaps it is because script in an HTML page is easily viewed by others, and the easier it is to understand, the easier it is for someone to "borrow." If this is a concern of yours, see Chapter 12, "Using Web Technologies," for information about protecting your script.