Dependency map for Java classes and methods

前端 未结 8 1473
予麋鹿
予麋鹿 2020-12-30 11:49

I have a Java project that I\'ve been working on for a while. The design started out pretty good but slowly degraded as changes were made. I\'m looking for some sort of to

相关标签:
8条回答
  • 2020-12-30 12:17

    You may want to check out JDepend. It was specifically developed to solve the problem you are facing.

    Working as a consultant it is very common for me to be thrown in to a huge legacy code base. Typically the first thing I do is run JDepend on it to try to get my bearing on the code base and all of the dependencies.

    Good luck.

    0 讨论(0)
  • 2020-12-30 12:17

    Many tools are available for this, depending on the size of your system. The grandaddy of them all is Structure101, a commercial product.

    http://structure101.com

    I've used this on some big projects - it's complex but easily the most comprehensive of all the tools I know. It can graph a huge architecture, and lets you untangle some complex stuff. It has a sister product called reStructure101 where you can do what-if scenarios.

    A nice competitor is Stan4j. It's nowhere near as complete, but does some stuff better, particularly showing the dependency context at the class level.

    http://www.stan4j.com

    (I own both products, but have no commercial affiliation with either)

    Another way of viewing complex dependencies, particularly at the project level, is a Dependency Structure Matrix (DSM). Although S101 can do a DSM, Lattix has more support - it can handle Spring and Hibernate dependencies:

    http://lattix.com/

    (I've not used lattix - they make it too hard to evaluate it, which is bizarre because I work on some very big systems)

    If your software is fairly small, and you are more interested in the simple class level, then something like Architexa may help you understand the structure better:

    http://www.architexa.com/

    Finally, if you want to roll your own, you can easily do this with ASM. It even includes a dependency matrix tool which tracks at the package level:

    http://asm.ow2.org/doc/tutorial-asm-2.0.html (see down the page for the nify dependency matrix)

    Here's the source for it - it's very simple, but clever. It works off bytecodes. http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/asm/asm/examples/dependencies/src/org/objectweb/asm/depend/

    0 讨论(0)
  • 2020-12-30 12:25

    There are several good analyzers for Java. I have been playing around with PMD so far and have had decent luck with it.

    0 讨论(0)
  • 2020-12-30 12:27

    We use this free small project

    http://www.devx.com/opensource/Article/33729

    0 讨论(0)
  • 2020-12-30 12:27

    Have a look at Apache Ivy

    0 讨论(0)
  • 2020-12-30 12:31

    This is not a perfect answer, but it may be helpful for quick checks. If you are using Eclipse for your development, you can view the call graph for a method by selecting its name and pressing Ctrl-Alt-H (or right-click and select "Open Call Hierarchy"). You can use the view that opens to see what calls the method, and what methods are called by the method.

    0 讨论(0)
提交回复
热议问题