Quick Glance at JArchitect
Few months ago Dane from JArchitect team was kind enough to provide me with a license for JArchitect 3.1.0
Professional Edition, a multiplatform (GNU/Linux, Mac, Windows) software for static code analysis.
While I was really swamped with my every-day work (and personal life) I didn’t have really much time to take a closer look at it that time.
Few days ago I’ve said to myself ‘that’s enough’ and X-rayed one of our company projects using JArchitect. Because of the fact that this is a commercial company project, during to my agreement I am not allowed to share any details about it with you, so I’ll just post some statistics and my general feedback about JArchitect.
The X-rayed project is a Java EE 6 application running on JBoss EAP 6.1 which contains of 25 000 LOC, 1647 types in 230 packages and it’s split in 17 Maven projects.
The first thing to notice is that this tool is really easy to use. You just create a new project, point to the Maven parent project and proceed with the import. JAarchitect recognizes whole project structure and analyzes all of them. It can produce a basic results as a HTML page with very similar measures to Sonar so we have a dependency matrix, application metrics, rules violations, etc. In the next screenshot you can see the dashboard of the generated HTML report page.
JArchitect bases on rules defined in a LinQ-like query language (CQLinq). It also allows you to create your own queries that, e.g. will notify you if particular method, type, field is matching the defined criteria. This way you doesn’t need to rely only on a set of predefined rules but you can also very dynamically create your own ones.
Another good idea is to provide you with a queries that can work only for new codebase. The rationale is quite understandable – if you already have a large codebase when you run JArchitect for the first one it will probably produce a lot of rules violations (it’s really not so uncommon.) Of course you are not able to run to the code and fix all those violations instead of pushing the project functionality forward. Therefore, you use adjust queries so the rules violations are raised only if they occur in the new code added to your codebase.
All those HTML reports are pretty complete perhaps excluding the diagrams on the dashboard which are only static images and not dynamic ones. But hey, that’s what the standalone JArchitect tool is for. It’s much more powerful and you can get to any given metric from it.
JArchitect Standalone Application
The GUI very much resembles all .NET / Visual Studio (it seems like it’s built on top of the Visual Studio – I’d
compare it to the iReport based on NetBeans, Eclipse RCP or things like that.) So all the icons (e.g. for methods,
fields, constructors) and style is taken from .NET / Visual Studio world.
I can’t say if it’s either wrong or good – it’s just different what I’m used to from Intellij IDEA, Eclipse or NetBeans as a Java developer.
JArchitect standalone is quite powerful analysis tool. You can browse all your codebase and view metrics (like size of the method in LOC, bytecode or cyclomatic complexity) for each single method, field or type.
You can see how it actually looks like on this pretty decent and brief movie.
In standalone application the dependency graph is interactive which is very useful. It uses idea similar to a tag cloud – the bigger the project (or library) size is – the more dependencies it has or uses. The arrows for dependencies also matters – the thicker the more dependencies are established between modules.
It allows to easily visualize dependencies and identify components that has probably too much responsibility or leaks too much of its internals and, probably, should be broken into smaller modules. This graph looks just like the one posted on the JArchitect site (shown below) but actually I’ve used a more high-level view (dependencies between projects – not types.)
At anytime you can view a list of rules, disable them, create your new ones (using mentioned CQLinq) or go to the classes that violates particular rules.
Besides that you also can view a dependency matrix (this one is quite similar to the Sonar Dependency Structure Matrix.)
You can see what project is using / depending on the other one and how many dependencies there are. Moreover, you are
able to extend each project and see what classes from it are the most highly dependent ones.
It allowed me to rapidly find out that some of our projects had too many dependencies on each other – think that I somehow missed using Sonar.
Then you have a “Metrics” tab which is similar to widely used GNU/Linux or Windows disk-usage diagrams:
You can visualize size of projects, classes, fields, etc.
Frankly, I wasn’t using this feature too much. Perhaps it might be useful for optimization, memory leaks or performance tasks but I was happy enough with the dependency matrix and graph.
.NET World Is Leaking Out
While using JArchitect I’ve noticed that it comes from the .NET world and there are a lot of things from .NET that are
“leaking” to JArchitect. It starts from the “getting started” presentations on the main dashboard of the application.
They are all named like “Getting started to analyze .NET assemblies” from “Visual NDepend movies” and so on.
I fully understand that JArchitect comes from NDepend branch but this creates some strange feeling that JArchitect is just an “add-on” for NDepend. This is not very pleasant.
By the way – I would really prefer to see a short interactive movies instead of those slide-shows. This is of course my personal opinion but it’s more fun to see someone working in the real-time (and talking about it during the footage) than to watch quite static presentation.
Nevertheless, movies contains universal information that can also be used in JArchitect (like creating queries which are an abstract layer – highly independent on the .NET or Java usage.)
You can also notice the NDepened presence if you try viewing reports from the HTML page (e.g. dependency graph or matrix). Each pop-up starts with “.NET Projects ….” title which also creates a bit strange feeling that you’re using .NET software for Java project.
Summing It Up
Basically, I’ve ran JArchitect analysis on a project that is pretty much finished. During the development time we’ve used Sonar (so PMD, Findbugs) as well as Checkstyle. I was pretty aware of many of the violations showed now in the JArchitect. However, at this point we’re just polishing the functionality and if there will be a possibility (budget and time) to develop another release or at least Change Request in the nearest future, I would love to see how JArchitect works for us.
Despite the previous project, I’m just starting a new one (we’re just after the specification phase) and I’m seriously
thinking about using JArchitect from the beginning of the project development. In this way I hope it’ll be much easier
to control the rules violations and to fix them as soon as possible.
If my plans will succeed I will keep you posted about the results and more insight details.
I guess that this pretty much summarizes what I think about this piece of software.
It needs a bit of polishing (if you .NET guys want to make us Java guys to feel like home :-) but it’s quite good addition to Sonar.
However, I would not resign from Sonar just for JArchitect. I don’t see that you use one or the other but rather that they complete each other.
Oh and by the way – two things that comes to my mind:
I would use the HTML reports only if JArchitect can be plugged into our CI server to generate such reports daily. However, I didn’t find any information about running it as e.g. a Hudson / Jenkins job. Is it even possible?
I would like to use my IDE of choice to edit files and fix rules violations from JArchitect. So it would be nice to have IDE (IDEA, Eclipse, …) integration with the JArchitect.
Finally, thank you Dane for giving me a chance to put my hands on the JArchitect tool and once again I’m terribly sorry that it took so much time. It was just not the best timing (because of marriage, house and other big topics :-)