Rapha's Rumination Promulgation

April 30, 2009

Visualising the Rhino code

Rhino is a reasonably large project. The current CVS head has 321 java files with 437 classes and interfaces over 116150 lines.

Being quite new to the code base, I thought it would be good to have some visual aids to help me better grasp the overall structure and see how things related to each other. A little bit of bash hackery later, and I came up with this:

This allows me to type:

$ ./visualise

from the rhino directory and a pdf image pops up, with a nice visualisation of the entire class hierarchy. This is just a cropped piece of it.

Rhino class hierarchy

The script above is obviously very primitive — it does simple string matching to extract the data, but it's enough for what I need right now, and it could be expanded to be much more informative and flexible if necessary.

The dependencies for this script are bash, ack and dot. It also uses MacOS' open command to display the generated file, but you could replace that with the name of whatever program you wanted to use to view it. If you're still using grep for you programming work, you could do a whole lot worse than giving ack a whirl (indeed if you don't, I contend you are). It's like an über-grep for programmers. dot is a very nice tool for drawing graphs (in the maths sense).

Inspiration for this kind of visualisation approach comes from my ThoughtWorks colleague, Erik Dörnenburg.