magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Hairball example I’ve been working on a tool called Hairball to track setter and constructor injection, and use of singletons in Java code. Right now, the tool is capable of creating dot diagrams (for use with GraphViz) and graphml diagrams (for display in yEd).

My initial motivation for hairball was as a tool to help me understand potential problems in my code bases – spot god classes, code that is hard to test, odd dependencies. The tool purposely doesn’t make any judgments about code bases – it just gives you the diagrams. What you do with them is up to you.

The first version doesn’t contain support for tracking of singleton dependencies, and the setter and constructor injection should very much be considered a first stab – so I could do with some beta testers. I’m looking to track down false positives and negatives, as well as get some general feedback. Is Hairball it easy to use? Does it misdetect dependencies? Can you read the diagrams? Does it blow up when trying to run on your mammoth code base (I’ve done nothing to tune performance)?

Future Features

I have a few more features I’d like to add, including:

  • Singleton detection
  • Displaying inheritance
  • Support spotting attribute injection from frameworks like Picocontainer or Guice
  • Overlaying other metrics (e.g. colour based on Emma output, make nodes taller based on number of instructions in the class)

The feedback I get will very much determine what gets added next.

Hairball is available now for download.

Advertisements

3 Responses to “Hairball”

  1. Carfield Yim

    Just try with a small project, the output is not easy to read, if you interested to take a look of the files I get may be you can email me??

    Reply
  2. sam

    Hi,

    Feel free to email me the file and I’ll take a look. Remember that by default hairball will show all dependencies – including primitives and stuff in java.lang. To just look at dependencies in your own code, run with the ‘-includePackages’ option. For example if your projects classes live in ‘org.mypackage’, run with ‘includePackages org.mypackage’.

    I’m also working on a version that will allow you to specify thresholds – for example only show a class that is depended on by > 5 classes, or a class that has more than 5 dependencies.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

%d bloggers like this: