For a long time we had a JDepend report running in our continuous build but it was rarely used or consulted. When I saw xxx presentation at QCon I thought it would be nice to straighten up the structure of our code base and start paying attention at some of the architectural qualities of the project.
Now I am willing to give Sonarj a try. It looks great and enable to control signal breaks in the package structure before they happen. One of the drawbacks is that it uses the package structure to describe architectural modules, which may be possible in green fields but is a bit challenging in an existing code base.
Meanwhile, I have given JDepend another look and in particular the possibility of integrating it with a test suite (JUnit at the moment but TestNG might enable to provide a nicer report rather than the blanket assertion). For now I am concentrating on the description and enforcement of the dependencies between packages.
@Test public void verifyDependencies() { thisPackage() .dependsOn("my.super.fantastic.package") .andOn("my.sortof.ok.package") .andItShouldNotDependOn("that.pesky.vendor.package") .orOn("my.very.bad.package"); assertItHasAllAndNoOtherDependencies(); }
This will break if new dependencies are created or existing dependencies are removed (see the base class DependencyTestBase).
A few things I would like to do in the future:
- a report of undesired dependencies that would give developers clues as to where they can make improvements,
- when the description of dependencies is not comprehensive it would be nice to forbid some dependencies,
- be able to set other thresholds for things like abstracted-ness.
As always, what do you think ? What other tools do you use for your architectural needs ? Sonarj (The demo at QCon was quiet interesting) ? Structure 101 ?