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!
A Java class has a dependency on another class, if it uses an instance of this class. We call this a class dependency. For example, a class which accesses a logger service has a dependency on this service class. Ideally Java classes should be as independent as possible from other Java classes.
Description. The jdeps command shows the package-level or class-level dependencies of Java class files. The input class can be a path name to a . class file, a directory, a JAR file, or it can be a fully qualified class name to analyze all class files. The options determine the output.
Dependency Injection in Java is a way to achieve Inversion of control (IoC) in our application by moving objects binding from compile time to runtime. We can achieve IoC through Factory Pattern, Template Method Design Pattern, Strategy Pattern and Service Locator pattern too.
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.
a trial of JAVADepend offers the possibility to analyse the dependency relationship you want with no limitation in time.
it's a nice tool.
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With