views:

399

answers:

5

As antiquated and painful as it is - I work at a company that continues to actively use VB6 for a large project. In fact, 18 months ago we came up against the 32k identifier limit.

Not willing to give up on the large code base and rewrite everything in .NET we broke our application into a main executable and several supporting DLL files. This week we ran into the 32k limit again.

The problem we have is that no tool we can find will tell us how many unique identifiers our source is using. We have no accurate way to gauge how our efforts are reducing the number of identifiers or how close we are to the limit before we reach it.

Does anyone know of a tool that will scan the source for a project and return some accurate metrics and statistics?

A: 
MaSuGaNa
Yes, but the asker needs a count of the number of variable declarations, and I can't see where CodeSmart shows that figure. Can you tell us where it should be? Thanks.
Binary Worrier
It is there, but I don't have image hosting to correct the screenshot from the manufacturer's website. If you download the Trial and install it you can run it and see for yourself.
MaSuGaNa
I've CodeSMART installed but I cannot find it. Can you tell the "path" of the tree where this value is displayed?
DR
Sure thing. Open up the CodeSmart Project Explorer (alternative to the VB Ctrl-R version) and drill into the objects to see more detail including lists of variable declares.
MaSuGaNa
I must be blind or something... I can see number of methods, public identifiers, but I cannot find the number of unique identifiers...
DR
Please see following post on Project Analyzer, CodeSmart will provide the information but not in a summarised form as you required.
MaSuGaNa
It's worse. It counts the number of *declarations*. If you just add them up, you don't get the number of unique identifiers. If two classes have the same property it counts only once!
DR
A: 

It seems that Compuware's DevPartner had that kind of code analysis. I don't know if the current version still supports Visual Basic 6.0. (But at least there's a 14-day trial available)

DR
A: 
MaSuGaNa
I wish this tool worked... It shows the number of variable declarations (as does CodeSMART) but it still doesn't show the number of unique identifiers. If you have three subs which all contain the same variable "myvar", then it counts as three variable declarations but just one unique identifier. Project analyzer only shows the count of declarations...
DR
A: 

You could get this from a tool that extracted identifiers from VB6 code. Then all you'd have to do is sort the list, eliminate duplicates, and measure the list size. We have a source code search engine that breaks up source code into language tokens ("lexes"), with some of those tokens being exactly those identifiers.f That would contain exactly the data you want.

But maybe there's another way to solve your problem: find out which variable names which occur rarely and replace them by a set of standard names (e.g., "temp"). So what you really want is a count of the number of each variable name so you can sort for "small numbers of references". The same lexer data can provide this information.

Then all you need is a tool to rename low-occurence identifiers to something from the standard set. We offer obfuscators that replace one name by another that could probably do this.

Ira Baxter
A: 

Cheat - create an unused class with #### unique variables in it. Use Excel or something to generate the alphabetical unique variable names. Remove the class from the project when you hit the limit, or comment out blocks of 100 unique variables..

I'd rather lean on the compiler (which defines how many variables are too many) than on some 3rd party tool anyway.

(oh crud, sorry to necro - didn't notice the dates)

Michael