Friday, September 03, 2010

Visualizing Code Aesthetics

In the newest Javamagazin, there's an article by Bastian Helfert and Steffen Hohn about CodeCity, a really interesting tool for visualizing code.

I just ran it over our 300k LOC Java project, and got this model (click to see larger version):

  • Buildings are classes. 
  • Height is based on class LOC
  • Building ground-area is based on number of attributes
  • City blocks are packages.
If you actually run the program, you can interact with the model, fly around, click to see which package is which block, etc.

This is all fun and cool-looking, but does it have any practical usage, I wonder?

I think we want to work in small friendly villages, where most houses are evenly-sized, nicely sized neighborhoods, no big ugly gray parking lots, and no towering sky-scrapers.

Here I ran it again on a smaller, nicer project:
Certainly a lot easier to find your way around this neighborhood.

I know Michael Feathers has made quite a few thoughts around code aesthetics. Perhaps these kind of metrics need some more attention to help people visualize good design and technical debt?