Visualise your ANT build with Grand

Ever had the feeling that your build file was a tad complex?

The above is a visualisation provided by the excellent program grand. This particular build script utilises the ASL ant library. I think it might need some love.

Producing the visualisation is very easy. Simply download the jar file and then some ant scripting…

You need to have GraphViz installed which should give you a command line program called “dot”. You can simply try :

dot –help

On the command line to see if you have it installed.

I have a working version on github


Walk the streets of your codebase: inFusion, Code City and a MOOSE

Moose is a framework built in Smalltalk for code analysis. Here’s a brief guide to get it up and running (at least on OS X). One very interesting application which is built on top of it is called CodeCity built by Richard Wettel. The instructions below are how you go about installing and using CodeCity. The picture above is a code city generated from a project I worked on.

The size of the building is determined by the number of methods, the width and length by the number of attributes and the colour by the number of lines of code (lighter blue is more lines of code). The “districts” are packages. You can see straight away from this view that we have one large “CBD” which is a result of us having a single package called “model” rather than more granular, domain related packages (.acccount, .customer, etc) which would be my preference.

A second immediate observation is that we have a syscraper; what is this? In this case, its actually a stub class, which shouldnt even be in the production codebase. Straight away we have found some value from the visualisation. I tend to believe that this may be a result of our IDE tools (such as CTRL+SHIFT+T or CTRL+N which allow us to browse classes by name). Whilst great for encouraging Ubiquitous language I think this view of the codebase is very focused and heads down, and when concentrating on delivery, perhaps we need to come up from the detail level every now and again. Its why I enjoy the package view in IntelliJ in which multiple source folders together and presents classes as top level “leaves” in the tree so that its easy to see the structure of your packages, compare to eclipse.

I recently printed out the city and stuck it on the wall and was pleasantly surprised by the interest it generated by passers by, so I think its a really useful tool for showing the team something which is inherently hard to “see”.

These instructions are for a java project.

1) Download inFusion

Although its commercial software you can download it and use it for free. It will read in your source code and save it to a file in Moose (Famix) format. This can then be used by CodeCity.

You can download inFusion here. On its own, inFusion is a useful metrics tool and provides some interesting visuals (see below) which I won’t cover in detail here. A good reference is Michele Lanzas’ work Object-oriented metrics in practice.

You can run inFusion as a gui to explore your codebase, or if you just want to get to code city, you can run it as a batch file.

To run the ui just go into

$: cd /Applications/inFusion/tools
$: ./

or (windows)

C:> inFusion.bat

To export the codebase in famix format (must be 2.1):

$: cd /Applications/inFusion/tools
$: ./ $SOURCE_DIR famix21 $TARGET_FILE

or (Windows)

C:> cd C:\development\external\inFusion\tools\inFusion
C:> java2mse.bat $SOURCE_DIR famix21 $TARGET_FILE

You may need to chmod +x the file.

On windows you can run the .bat file.

2) Load your source code

(theres a folder icon on the right). This takes a while and eventually presents you with a html view of your project stats in the bottom window.

An example of the output is shown here:

To do anything interesting, you right click (or two finger-click on a macbook trackpad) over “java” this will be whatever the name of your root directory is, maybe “src”.

One option there is to Run tool -> Famix 2.1 exporter. This is the format you want to export for code city. Its important that its 2.1

Again you might have to chmod +x the script.

Notice that you can also run another extremely cool tool, called DuDe which analyses duplicate code fragments in your code base.

3) Now your ready for code city

Download it from here.

There are versions for windows os x and linux.

The os x app is very handy and simply runs.

4) Import your MSE file

“Import Model(s) from …” “an MSE file” button.

5) View the city!

There are some keyboard shortcuts which werent obvious to me (help -> key mapping). You do W to “zoom in”, “S” to zoom out, “A” to move the whole scene left and “D” to move the whole scene right.

You can then navigate around using the arrow keys. If you press CTRL with the arrows, you rotate around the sphere of observation.

Some other cool features are to toggle contextual edges on (its a menubar icon, hover over them). You can configure contextual edges with incoming or outgoing invocations and then select an object and see “wires” indicating where the connections are.

Other features:

Make a snapshot of the picture as png
Import a set of MSE files and see an evolving city
View class blueprint of the classes

Enjoy your city!


Visualise codebase evolution with gource

This rocks.

Instructions for what I did to get it up and running are below. Once you have it, just go into an folder with a git repo and type:


A few minutes later and you are watching your codebase being built by mini avatars. This is an amazing visualisation, just need to work out how it can be used. I suspect that it might help teams to look back over time and see how much things have grown and where all the work goes. Potentially it could be synchronised to other visualisations to explore the history of a codebase.

Nyway, here are my steps to install:

There are instructions on the googlecode site. I’m running OS X and so can install with MacPorts.

First I needed to update and sync my macports. I tried using the port selfupdate but it didnt work for me so I just downloaded and installed the DMG from the ports site, but in theory you should be able to do:

sudo port selfupdate
sudo port sync

Then install.

Also I got

dyld: Library not loaded: /opt/local/lib/libjpeg.62.dylib

So needed to update tiff

sudo port install tiff
sudo port install gource