views:

115

answers:

8

We have a Java code base that has grown to be too big for a single monolithic JAR (more than 5000 classes). One of the tasks that we are investigating is how much effort would it be to break this single JAR into smaller components with controlled dependencies between them. However, it's somewhat hard to look at a big bag of code and be sure that you are finding the best points of separation without some analysis.

Are there good tools to inspect and visualize the interpackage dependencies? Given those, we would have a set of suggested cut points where we could begin separating code.

As an example, in the days before Netbeans and Eclipse (and at a different job), we used TogetherJ and TogetherEnterprise. Those had the ability to do a static package analysis and draw the UML diagram. That sort of behavior would be optimal but that feature alone is not sufficient to justify the cost.

+1  A: 

SonarJ is a good tool to do that, but it is expensive.

Another very good tool is XDepend, which is cheaper. For your purpose, I would recommand you this tool. The best choice in terms of quality/price I think.

With much less functionalities, you can use a Sonar (Free and OpenSource) analysis and its dependencies matrix.

Benoit Courtine
A: 

Do the classes use packages in a normal fashion or are all the classes in the same package? If the first case is true, I'd consider writing a special-purpose tool to do the first cut.

Tony Ennis
@Tony, the original architecture laid things out in a reasonable fashion. However, years of customer requests and new development have lead to years of edits and it's time to wrangle all that back together. 5000 classes in one package would be gross, wouldn't it?
Bob Cross
@bob cross - yes indeed. I think I'd have to play with it for a while to determine even how to proceed.
Tony Ennis
A: 

I used stan4j for the same purpose but unfortunately the community edition has a 500 classes limit. On the other side, it works as an eclipse extension.

andcoz
+3  A: 

I have recently discovered CodePro AnalytiX, formerly from Instantiations, now available for free from Google: http://code.google.com/webtoolkit/tools/codepro/doc/features/dependencies/dependencies.html

Fabian Steeg
@Fabian, +1 for free!
Bob Cross
+2  A: 

Intellij IDEA has one:

alt text

OscarRyz
+1  A: 

JDepend is a free tool for analyzing package dependencies.

It identifies circular dependencies, which would impede breaking this monolith into smaller pieces.

We put this check for circular dependencies into our unit tests, to prevent them from the start.

There's a corresponding Eclipse plug-in.

You can send the output to GraphViz. However, the visualization becomes less understandable as the number of packages grows.

Now that CodePro AnalytiX [mentioned first by Fabian Steeg above] is free, it's worth another look. At least prior to purchase by Google, Instantiations reliably produced great software. I played with it some years back, and recall no complaints other than cost.

Andy Thomas-Cramer
A: 

A good try would be to reverse your jar file into a class diagram. I have found this tutorial which explain how to reverse project composed by jar files into UML class diagram: http://www.ejb3.org/jar_file_reverse/jar_file_reverse.html

You will be able to reverse at package level at see package relation but also to see clases from one package having relation to other packages. Once the project has been reversed you can reorganize it as a model and give this documentation to the implementation team.

alt text

+1  A: 

When a codebase is large and less than ideally structured the key is not just visualization but analysis.

Take a look at Structure101.

See the screenshot below or view it larger.

alt text

pth