FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Architecture & Design
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
March 01, 2001
Walking in CodeRover Boots

(Page 1 of 2)

March 2001: Walking in CodeRover Boots

Back in college, I did a lot of hiking. At one point, I got enough money together to get a really good pair of boots. They were Fabianos, big, heavy, leather monsters. Shortly thereafter, I blithely laced them up for a five-mile hike—and crawled home with hamburger feet. Over time, though, they broke in to my feet (or maybe it was the other way around), and I still have them. They look funny now: knobs, bumps, creases all over. But when I put them on, my feet go "Aaaaaah." Every bump in the boot fits a bump on my foot, and they feel like three-pound slippers.

No, CodeRover is not an old boot. Far from it. But, like a hiking boot, the fit will be very important. Its products can either help you-a lot-or drive you crazy. Don't decide too quickly which is which, because it may take a little while for them to break in to your personal routine.

In this review, I examine CodeRover Browser, which helps you navigate your code, and CodeRover Integrity, which tracks changes to your source code and calculates quality metrics.

CodeRover Browser
Browser is CodeRover's basic platform; Integrity adds functionality to it. If you purchase Integrity, it comes with Browser, but you can also purchase Browser separately, without Integrity.

I obtained Browser as a download from Upspring software, along with an e-mail containing license data and instructions on how to activate it. Nothing complicated here; I just had to run the downloaded EXE to install, save the e-mail as a text file, set an environment variable to point to it, and run the program.

Next, I gave it a few projects to chew on:

  • The Visual C++ "typical Hello World application," which is a do-nothing Windows application in C.
  • A Microsoft Foundation Classes application generated by the MFC AppWizard in C++.
  • The Apache Web server source, which is mostly in C.

I took a flying leap before trying to crawl, and threw the Apache Web server source distribution at CodeRover. Ouch. OK, let's try the Hello World application. In fact, let's read the documentation!

Much better. By following the simple instructions for teaching Visual C++ about CodeRover, you get a toolbar in Visual C++ with CodeRover buttons on it. Clicking the Start CodeRover button brings up a startup dialog. You can click the Build button to collect the information CodeRover needs to browse and analyze your project (which it calls a "model"), or the Browse button to use a preexisting model.

Building the model takes a while. On my 650MHz Athlon with 256MB RAM, it took longer than two minutes for the do-nothing "Hello World" application to compile. (Compiling the same application from scratch in Visual C++ , by contrast, takes about eight seconds.) So, once you have a model, you'll want to keep it around as long as you can. (This turns out to be a problem, because if you want to use some of the more advanced features, you have to rebuild the model whenever the source code changes out from under it.)

With the model built, the browser window appears (Figure 1). It defaults to showing you every entity in your program, but you can narrow the selection with several controls, such as tree control, combo box and filter bar. The tree control lets you selectively browse different folders in your project, the combo box lets you select the kind of entities to be displayed, and the filter bar lets you filter the entity names using a text search. Once you get used to the combination, you'll be able to quickly zero in on a particular piece of code.

Figure 1. The Browser Window

The Browser defaults to showing you every entity in your program, but you can narrow the selection with several controls, such as tree control, combo box and filter bar.

 

For instance, from the mess of entities in Figure 1, I decided to look at allocation functions. When I selected Functions from the combo box, nothing happened until I remembered I needed to click the Go! button. After that, CodeRover thought for a moment, then displayed a list of every function referred to in the program. I typed "alloc" into the filter bar, and there was my answer. When I did this, I noticed the search string can appear anywhere in the name, and didn't have to start with "alloc"—a nice feature.

Passing the cursor over each entry pops up a tooltip with the return type. From a list of entities, you can do several interesting things:

  • Double-click one to bring up its definition in your source editor (you get to pick the editor-currently Visual C++ , Emacs, VIM or JBuilder).
  • Click the Source tab to view the source in the browser.
  • For functions, click the Call Tree tab to see a map of a function's callers and callees.
  • For classes, click the Inheritance tab to bring up the Inheritance tree.
  • Use the menus to see a whole raft of stuff. Depending on the entity selected, the pull-down menus include Defines (functions defined within a module), Uses (constants used inside a function), Where (Used, Called, Defined, Declared, Included, Referenced), and Show (Fields or Friends). Selecting a menu item brings up a new list of entities.

It's annoying that there is no obvious way to tell which entities are yours, and which belong to the system. You have to click on one and then pick an operation (and often watch the progress bar for several seconds) to determine if the source is available.

All this is a bit more comprehensible and useful, I found, with a C++ program. I created an empty Visual C++ application, named it Example, and pointed the browser at it. Eight minutes later, the browser opened. I selected "Classes" … nothing … oh yeah, click "Go!" With a large list of entities displayed, I typed "example" into the filter box. Blam! Text filtering is lightning-fast.

Now suppose you need to see which classes are referred to in CExampleApp::InitInstance(). You'd just need to select CExampleApp from the list of filtered classes and pull down "Uses | Classes." The results in Figure 2 show CMainFrame selected in both Visual C++ and the Browser, ready to perform further exploration or modify the source.

Figure 2. Example Classes

The results show CMainFrame selected in both Visual C++ and the Browser, ready to perform further exploration or modify the source.

A special solid-gold note of thanks to the person who came up with the green arrow keys at the bottom: They function like a Web browser's "back" and "forward" buttons, letting you unravel a chain of selections and filters one by one, and branch off again if need be. Once I learned to use those little gems, I found myself thinking, "Gee, this would be kind of neat for my own code. Too bad it's all in Java." Then I checked the Web site and found that Upspring offers C++, C++ and Java, and Java flavors of Browser. I did a quick test, and saw that it does indeed work with Java, too.

CodeRover Integrity
OK, you've sent CodeRover barking all over your code. You finally feel like you understand the software your team is writing. But is it any good?

More to the point, when you idly skimmed the revision control logs this morning, you noticed somebody had half the code base checked out for a week. Hey, it was that clown in the user interface group. How badly has he broken things?

Fear not. CodeRover Integrity can be your secret weapon. Integrity collects quality information on a project, then flags changes to the code quality from build to build. The combination can be a real confidence-enhancer—but there are some caveats.

Once you've built a CodeRover model, you're halfway to using Integrity. Later, after some changes have been made to the source, it's time to run another model build. At that point, the Integrity tab becomes enabled. Integrity will assess the differences between its previous analysis of the code and the latest one, and display the results under five headings: General, Portability, Globalization, Structure and Statistics.

Expanding the General heading shows a list of static quality rules that Integrity applies to your code. For example, in Figure 3, there is a switch statement that lacks a default clause, and Integrity is indicating where to look for it.

Figure 3. Expanding the General Heading

There is a switch statement that lacks a default clause, and Integrity is indicating where to look for it.

 

Clicking the Source tab shows the offending statement. I figured that if double-clicking an entity in the Browser jumped my Visual C++ session to the definition, double-clicking the "hit" line should work, right? Wrong.

Also, note that you'll only get notified of new violations. Integrity accepts the code in your initial model build as gospel (or, more frustrating, tells you there is a violation, while coyly keeping the location a secret).

On a good note, I really liked Integrity's use of the tree widget. A system of colored icons tells you at a glance whether a rule has a "hit," and whether it's good or bad. For example, a red "bug" icon means a rule violation has appeared since the last model build—probably something you should check right away. Other icons tell you if a rule violation was present last time too, or when one was corrected. And the flags propagate right up the tree, so you can tell immediately whether or not a branch needs to be explored further.

As for the actual tests performed, there are too many to list here. Some are things that your compiler should warn you about (such as conversion between unrelated pointer types); others will be significant, or not, depending on your own coding standards (a class defined with friends, for example). I encourage you to check out the list.

The Portability heading shows whether or not your code violates rules like using inline assembly code or directly comparing two floating-point values (rounding errors might trip you up here).

Globalization looks for things like string literals in your code, along with more subtle problems like pointer arithmetic with strings (What if your new character set uses two-byte characters?).

Structure ensures your code passes "standards" tests like how many lines of code a module may contain, or how high a cyclomatic complexity score it may attain.

Finally, Statistics gives you an interesting set of metrics on your source code, starting with the infamous SLOC (source lines of code) and progressing from there.

Here He Goes Again
I seem to have this section in all my reviews. A few things just bugged me about these products. Like the comedian (now football announcer) Dennis Miller, I wouldn't want to go on a rant or anything …

Let's start with a little quibble or two. Maybe it's just the state of the computing art or Java performance issues or something. But in this age of direct-manipulation user interfaces, I find it jarring to have to collect my choices, and then have to press a separate Go! button. And how about those model builds? As noted above, Visual C++ would compile projects from scratch in less time than it took CodeRover to build its model. Visual C++ builds Apache from downloaded source to a functioning Web server in under a minute on my machine; the corresponding CodeRover model build had me staring at the progress bars for more than eight!

Speaking of progress bars, I have a plea to all of you out there, not just Upspring: If you're going to show one, make 100 percent mean 100 percent! Please don't sprint to 25 percent, stall there for half the total time, then zoom to 99. And when you get to 100 percent, I want that baby to be done. If it's too hard to make the progress bar accurate (and heaven knows I find it a challenge), then use something else that shows progress happening, but only gives a general idea how fast things are moving. (Upspring took a commendable swing at this with a bar that goes back and forth, changing colors all the while, but it's still too close to the common progress bar idiom.)

OK, OK, I rant, but details like this really are important. Our user interfaces are the only way we talk to the users. If they fib, our credibility erodes.

Is It Worth It?
Several of the Browser's functions, as you're probably aware, are already provided by a good IDE like Visual C++. A good engineer who knows his or her way around the Visual C++ environment can jump from use to definition to "next function" fast enough to make your head spin. CodeRover Browser does provide a much more comprehensive list of ways to get at your source, though. The larger your source code base, the more time your team probably spends swimming around in it, looking for things, and the more help CodeRover Browser can be to you. That "good engineer" may be the sole employee who knows the code well enough to whirl around in it. CodeRover Browser might enable similar agility in … well, not to put too fine a point on it, people like me.

Likewise, you can find tools to measure many of the problems that Integrity seeks. However, having them in an integrated environment lowers the barrier to entry, to the point where you won't just have trained QA people analyzing the code, but the programmers themselves. Again, the bigger your projects, the more useful you'll probably find Integrity.

You can try the Browser for free, and I recommend that you do. But don't just run it once. Walk around in it for a few days. Break it in a little. You just might find that it's growing on you. If it does, a look at your quality assurance needs will tell you if you want Integrity too.

CodeRover Browser for C/C++ and Integrity 2.0

Upspring Software Inc.
15 Third Ave.
Burlington, MA 01803
Tel: (781) 359-3300
Fax: (781) 359-3399

Online: www.upspringsoftware.com

Price: CodeRover Browser C/C++ costs $195, trial download available; CodeRover Integrity costs $595.
Technical Requirements:
Hardware: 200MHz Pentium processor, 128MB RAM
Software: Windows NT or 2000 (only), Visual C++ Version 5 or later

RATING: **** The Rate Sheet
Pros:
  1. Browser helps manage the complexity of a large code base.

  2. By identifying relationships, programmers can assess the impact of changes.
  3. Integrity lets you track project quality over time with a variety of metrics.

Cons:

  1. Integrity alerts you to new problems since your last model build, but is less helpful with your initial source snapshot.
  2. The query and result user interface (instead of more direct manipulation) can be annoying.
  3. Must frequently stop and wait; the model rebuild process, required when source has changed, is especially painful.

1 | 2 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK