Enterprise Java

JArchitect became free for Java open source contributors

JArchitect is a static analysis tool for Java codebases that provides interactive GUI(s) and HTML reports for finding overly complex or problematic areas of your code, performing analysis for refactoring and comparing changes over time. In version 3, a LINQ-like query language was added that makes the tool an extremely powerful reporting engine and can be used to enforce coding standards rules on your build systems. Here are some useful JArchitect features:

CQLinq

The cool and powerful feature of the JArchitect is the support for Code Query Linq (CQLinq). The CQLinq lets the developers to query the Java code using LINQ queries,

for example CQlinq can answer to the following requests:

– Which methods create objects of a particular class?

from m in Methods where m.CreateA (“MyPackage.MyClass”) select m

-Which methods assign a particular field?

from m in Methods where m.AssignField(“MyNamespace.MyClass.m_Field”) select m

-Which complex method is not enough commented?

from m in Application.Methods where m.CyclomaticComplexity > 15 && m.PercentageComment < 10. Select new { m, m.CyclomaticComplexity, m.PercentageComment }. You can also be warned automatically when a CQLinq query returns a certain result. For example I don’t want that my User Interface layer to depend directly on the DataBase layer:

warnif count > 0

from p in Packages where p.IsUsing(“DataLayer”) && (n.Name == @”UILayer”) select p

JArchitect provides more than 80 metrics that are related to your code organization, code quality and code structure. These metrics could be used in CQLinq to create your coding custom rules, JArchitect could be integrated into your build system to enforce the quality of your codebase.

Dependency graph

The dependency graph is very useful to explore the existing codebase, we can go inside any project, package or class to discover dependencies between code elements.

photo1

Dependency Matrix

The DSM (Dependency Structure Matrix) is a compact way to represent and navigate across dependencies between components.

image2

Why using two different ways, graph and DSM, to represent the same information? Because there is a
trade-off:

  1. Graph is more intuitive but can be totally not understandable when the numbers of nodes and edges grow (a few dozens boxes can be enough to produce a graph too complex)
  2. DSM is less intuitive but can be very efficient to represent large and complex graph. We say that DSM scales compare to graph.

Metric view

In the Metric View, the code base is represented through a Treemap. Treemapping is a method for displaying tree-structured data by using nested rectangles. The tree structure used in JArchitect treemap is the usual code hierarchy:

  • Java projects contain packages
  • Packages contain types
  • Types contains methods and fields

With treemap rectangles represent code elements. The option level determines the kind of code element represented by unit rectangles. The option level can take the 5 values: project, package, type, method and field. The two screenshots below shows the same code base represented through type level on left, and namespace level on right.

image3

If a CQLinq query is currently edited, the set of code elements matched by the query is shown on the treemap as a set of blue rectangles. It’s very helpful to see visually the code elements concerned by a specific CQLinq request.

Compare build

In software development, products are constantly evolving. Hence, developers and architects must pay attention to modifications in code bases. Modern source code repositories handle incremental development. They can enumerate differences between 2 versions of source code files. JArchitect can tell you what has been changed between 2 builds but it does more than simple text comparison. It can distinguish between comment change and code change, between what has been added/removed and what has just been modified. With JArchitect, you can see how code metrics are evolving and you know if coupling between components is increasing or not. JArchitect can also continuously check modifications to warn you as soon as a breaking compatibility changes.

Generate custom reports

JArchitect can analyze source code and Java Projects through JArchitect.Console.exe. Each time it analyzes a code base, JArchitect yields a report that can inform you about the status of your development. You can customize sections shown in the report and you can even provide your own XSL sheet for full customization. You can also build your own set of CQLinq constraints that will be checked at each analysis. The report will warn you each time a constraint is violated. This feature makes automatic design and quality regression test a reality.

JArchitect provides a pro license to all open source Java contributors. It could be useful to analyze their code base. So, if you would like to give it a try, check here for more details. Happy coding!

Ilias Tsagklis

Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button