12

I know a lot of related questions have been given on SO, but I've not been able to find anything fully satisfactory - probably because my requirement is slightly different from each of those questions raised.

I have a gigantic codebase that I'd like to break down into smaller logic units. To do this, I need to find all the tangled/circular dependencies and resolve them. Due to the size of the existing spaghetti, the only feasible strategy appears to be divide-and-conquer, so I need to divide the huge project into smaller pieces first or peel off independent parts and tackle the smaller pieces separately.

Most of the tools I can find out there seems to only work on the class or package level, but they don't seem to support the concept of sub-packages. For example, If I have a root package, 3 packages under that, and then 5 subpackages under each of the 3, then I'll get 1+3+15=19 packages, which will give me a crazily complicated graph. Now what I hope to be able to do is to analyze the dependency relationship between the 3 top level packages first (number of incoming/outgoing packages, and which classes originate these dependencies), clean it up on that level, before diving into these top level packages to work on the next level.

Now, I've used Structure 101 for this purpose, and it works great, but when the trial expires, the price of the product is a little steep for my budget. Is there a free/open source solution out there?

Thanks in advance!

0

8 Answers 8

6

To my knowledge there is no free tool that is remotely comparable to structure 101. (I am not affiliated!)

So you already have a solution, but you say the pricing is too high. This may be a fallacy.

I have a gigantic codebase that I'd like to break down into smaller logic units.

Presumably you're not doing this for fun but somebody is paying you to do it. The USD 900 for structure 101 is around 3-4 days of work - assuming you make something like HKD 40k (USD 5200) per month as a senior software developer in Hong Kong. It should be possible to make the argument that this will actually save a lot of money in the end.

Sign up to request clarification or add additional context in comments.

7 Comments

Economy is not about 'saving' but 'optimizing'.
I concur, but in marketing you always "save money" even if you spend it :-)
Thanks. "paying for what you get" is exactly the point here. You see, I agree that structure 101 is an awesome piece of work, but it does much more than what I need, so the price I'll have to pay for it is only buying me something that's worth a lot less than that. I'm not looking for a full-featured do-it-all software. I've found a couple of alternatives that almost do all that I need, and it's just this "including subpackages" bit that most of them don't seem to do which doesn't strike me as being "challenging". So I'm thinking someone out there must have made it available.
Btw, I'm now checking out ispace which seems to be pretty nice piece of work!
@RAY Interesting indeed, I did not known about it. A pity that development has stopped in 2007.
|
2

a trial of JAVADepend offers the possibility to analyse the dependency relationship you want with no limitation in time.

it's a nice tool.

1 Comment

There wouldn't happen to be a paid version that is a little cheaper by any chance?
2

project: https://github.com/lukehutch/fast-classpath-scanner

how to use latest tips/news: https://github.com/lukehutch/fast-classpath-scanner/releases

pre-compiled jars+source: https://oss.sonatype.org/#nexus-search;quick~fast-classpath-scanner

example: https://github.com/lukehutch/fast-classpath-scanner/wiki/3.9.-Generating-a-GraphViz-dot-file-from-the-classgraph

ScanResult scanResult = new FastClasspathScanner(
  MyClass.class.getPackage().getName()).scan();
String str = scanResult.generateClassGraphDotFile(9.2f, 8.0f);

Files.write(str, new File("GraphViz.dot"), StandardCharsets.UTF_8);

System.out.println("now run this at terminal: dot -Tsvg < GraphViz.dot > GraphViz.svg");

1 Comment

The API for this has changed in version 4 -- see the docs here: github.com/fast-classpath-scanner/fast-classpath-scanner I will add a more complete example as a separate answer.
1

Have a look at CodePro Analytix. It has several tools for dependency analysis plus tons of other things that you should be aware of.

For offline analysis, look at SonarQube. It has no dependency graph but has a module for dependency cycles in your classes plus a ton of quality measurement modules.

Comments

0

Have you looked at either ObjectAID or PlantUML plug-ins for eclipse? Not as robust as what you're asking about, but definitely provide some good UML modelling mechanisms for free.

Comments

0

Disclaimer: I'm the author of coffea

I taught I should share, since I'm facing a similar problem, again (i.e. a gigantic codebase with multilevel, complex package dependencies and hardly any structure), and I'm not aware of any free alternatives available for the moment.

In my opinion, nothing beats scripting and/or explicit grouping rules when dealing with a chaotic package structure, and since I didn't find any reasonable way to do this earlier, I rolled out my own tool.

Of course, this will not beat any commercial alternative, but it's a fairly simple approach, that should allow you to investigate the interesting parts without the surrounding noise.

Comments

0

Try FastClasspathScanner: https://github.com/fast-classpath-scanner/fast-classpath-scanner (Disclaimer, I am the author)

For example:

try (PrintWriter out = new PrintWriter("/tmp/classgraph.dot")) {
    out.print(new FastClasspathScanner()
        .whitelistPackages("com.xyz")
        .enableAllInfo()
        .scan()
        .getAllClasses()
        .generateGraphVizDotFile(
            sizeX, sizeY, showFields, showMethods, showAnnotations
        ));
}

Comments

0

I just tried out "Programmer's Friend Class Dependency Analyzer (CDA) 2.4.1" and it turns out to be a really neat tool, which lazy loads depencies so it is quite fast to use.

Hope it can help someone else.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.