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)?
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.
3 Responses to “Hairball”
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??
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.
The images on the Hairball website both link to the same flickr image: http://www.flickr.com/photos/samnewman/752156236/ when the 2nd one should link to: http://www.flickr.com/photos/samnewman/751541295/in/set-72157600710448082/