开发者

Is there a visualization tool that can inspect a Java code base and report inter-package dependencies?

开发者 https://www.devze.com 2023-01-18 16:17 出处:网络
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 effor开发者_开发技巧t would it be to b

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 effor开发者_开发技巧t 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.


I have recently discovered CodePro AnalytiX, formerly from Instantiations, now available for free from Google: https://developers.google.com/java-dev-tools/codepro/doc/features/dependencies/dependencies


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.


Intellij IDEA has one:

Is there a visualization tool that can inspect a Java code base and report inter-package dependencies?


(source: jetbrains.com)


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.


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.

Is there a visualization tool that can inspect a Java code base and report inter-package dependencies?


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.


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.


This is exactly the kind of use case I build degraph for.

It allows you to define slices, i.e. sets of classes that belong together, and visualizes them as one collapsible node. You jars to be would be slices that you can tweak until they don't have any more cyclic dependencies, at which point they can become their own jar.

This makes it easy to spot dependencies between slices that you need to break. Since you can open the slice node and see all the contained classes it makes it also easy to identify possible refactorings (introducing interfaces, moving classes ..) to achieve you goal.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号