Owners of ugly code: Take note of Total Visual CodeTools 2002

Nonstandard code is hard to read and a haven for bugs, but manually cleaning it up is far too laborious. That's where Total Visual CodeTools 2002 comes in. Find out how this product takes the work out of standardizing and maintaining your code.

Visual Basic and VBA are so ubiquitous and easy to use, practically anyone can write working VB code. The trouble is, working code isn't always readable. FMS, Inc's Total Visual CodeTools 2002 is a suite of VB IDE add-ins that can help programmers beautify and maintain their VB code.

Total Visual CodeTools (TVCT) consists of three main modules:
  • Code Cleanup helps bring deviant VB code back in line with standards.
  • The Code Delivery tool helps get code ready for production.
  • A set of miscellaneous IDE enhancements lives on the TVCT toolbar (Figure A) and automates some common tasks.

Figure A
The Total Visual CodeTools toolbar

Standards driven
Options for most of the tools in TVCT are controlled via a configuration file called a "standards file." In it, you define, through TVCT's front-end, style templates for error handlers and comments, acceptable variable prefixes, and other things affecting the code that TVCT's tools generate. The standards file can be password protected and located on a central server, making it easy to make sure the whole team is using the same configuration. The out-of-the-box configuration is fairly decent and should be adequate for most small or medium-size shops, but TVCT is customizable enough that larger shops should be able to make use of it as well.

Standardize your code
The bulk of TVCT's features lie in the Code Cleanup tool. If you have the misfortune of adopting someone else's less-than-elegant code, you'll see the usefulness of Code Cleanup's beautification features immediately. You define what you want Code Cleanup to look for and fix and then run the tool on a single procedure or on one or multiple modules, go get a cup of coffee, and when you come back, you've magically got readable code.

Code Cleanup will add standard error-handling stubs and comment headers to each procedure in a module based on the templates you define in the standards file. You can also use it to straighten out style issues, such as breaking compound statements like one-line If… Then constructs into multiple lines and indenting blocks of code. In addition, there are options to give variables standard or custom type prefixes and to sort procedures based on their declared scope.

Code Cleanup displays a list of the changes that it thinks it should make after it finishes running, so you get a chance to approve them before they become final. That's a nice touch, but unfortunately, you aren't able to reject or accept individual changes made to a module; instead, it's all or nothing. Neither can you set Code Cleanup to exclude individual procedures in a module from modification. The downloadable trial of TVCT doesn't allow examination of multiple modules, so I wasn't able to tell if changes to individual modules could be rejected.

Gearing up for production
Let's say that your project's done and is being rolled out to production or distributed. That's when George the Junior Programmer announces that he accidentally left a Stop statement lying somewhere in his code. He knows he's supposed to search for and remove those before turning his final code back in, but he got distracted by Jim the Consultant's 18-button, quad-laser, optical, gyroscopically stabilized cordless mouse and forgot to check that procedure.

Code Delivery is designed to catch things like left-behind Stop and Debug statements and remove them automatically. It can also obfuscate your source code by removing indents and comments or replacing descriptive variable names with generic ones like V1, V2, and so on. The big money feature, however, has to be the addition of line numbers to procedures to facilitate the use of line numbers in error messages.

Like its cousin, Code Delivery can be run on an individual procedure, a single module, or multiple modules. It gives you a list of proposed changes, but you can reject or accept only an entire set of changes, not individual ones. Incidentally, Code Cleanup can remove the line numbers put into a module by Code Delivery.

IDE miscellany
The TVCT toolbar features a set of IDE enhancement tools, along with Code Cleanup and Code Delivery. The tools include:
  • New procedure and property builders.
  • An ADO and DAO recordset builder.
  • Message box and Case statement wizards.
  • A Long Text/SQL Builder that automatically breaks long strings and SQL statements into multiple lines.
  • A block comment marker.
  • A tool for changing the colors used by the VB IDE for things like syntax highlighting.

You can paste the output of each builder or wizard directly into a code module, onto the Clipboard, or into Notepad. The latter is especially useful if you happen to find yourself doing a little ASP or scripting work.

At roughly $299 a seat (multiple-license discounts are available), TVCT might seem a little expensive. But if you or your team frequently have to clean up ugly code, the features in Code Cleanup by themselves are worth the purchase price.

What is your favorite VB tool?
Do you have a favorite tool, utility, or add-in that you can’t live without? Share the wealth. Send us an e-mail with your recommendations or post a comment below.


Editor's Picks