DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. SonarJ Upgrades Architectural Dependency Tracking

SonarJ Upgrades Architectural Dependency Tracking

Mitch Pronschinske user avatar by
Mitch Pronschinske
·
Mar. 04, 10 · Interview
Like (0)
Save
Tweet
Share
25.87K Views

Join the DZone community and get the full member experience.

Join For Free
A German company, Hello2morrow, recently launched a new version of its tool for bridging the gap between architects and developers.  SonarJ allows developers to validate their code against large software architectures using static analysis.  It exists as a standalone version, an Eclipse plugin, and as a Maven plugin or Ant task.  SonarJ 5.1.1 and the Sonar plugin 1.2 for SonarJ were recently unveiled with new features including enhanced Excel exporting of dependencies for SonarJ and multi-module Maven project support for the plugin.

SonarJ is used to build project architectures (or use existing ones) and map a system model to the code.  The architecture logic built in SonarJ defines a "blueprint" of layers, vertical slices and subsystems.  SonarJ then takes guidelines and distributes them to the development teams as an XML file.  Finally, it monitors the changes and notifies developers when a quality or architectural violation occurs.  The program can then provide a simple workflow for assigning issue fixes.  All of this is done within the IDE.  

SonarJ Maps Cyclic Dependencies

SonarJ was used to detect dependency cycles in Spring's architecture

Developers can choose to use SonarJ as an Eclipse plugin or as a standalone version which can integrate with most other development environments.  The software supports anything that ends in Java bytecode and most of the analysis is done on the bytecode level.  SonarJ also corrects architectural problems by simulating and planning refactorings.  Large monolithic systems can be partitioned and modularized with SonarJ's ability to visualize dependency structures and simulate refactorings.  SonarJ's dependency visualization also detects cyclic dependency structures on multiple levels and improves QA.  Overall, SonarJ is useful because it lets developers know if their code really reflects the architecture.  Without a tool like SonarJ, an architecture only exists in the form of documents or UML diagrams; you never really know if your code reflects the architecture.

Hello2morrow founder Alexander on Zitzewitz further explains SonarJ's capabilities:

"The mapping is done by assigning Java elements like packages or types to the artifacts of the logical architecture. As soon as this had been done we can automatically compare the logical architecture with the code base and find and display all violations (dependencies, that are not foreseen in the logical architecture).  This feature is of course especially useful in the Eclipse plugin, where violations are marked with error markers as soon as the developer saves a code change. This check is done within milliseconds because SonarJ always keeps a very compact model of the code in memory so that only changed files need to be reparsed.  Besides checking the structure, SonarJ can also check a couple of relevant software metrics and warn the developer, when a metric is out of range."

What's New?

  • Code Block Duplication - SonarJ is now able to locate duplicate code blocks using a high-performance algorithm.  This feature mitigates the problems caused by by copy & paste programming.
  • New Package Level Refactorings - Version 5.1.1's virtual refactoring engine includes new package-level refactorings that make it easier to delegate virtual refactorings to Eclipse for execution.
  • Partially Opened Project Support - The classes and sources analyzed by the Eclipse plugin have more flexible management options that allow SonarJ to work effectively even if your project is only partially opened.
  • Enhanced Excel Export - When you need to know all dependencies between a set of .jar files you can use the exploration view to visualize dependencies (switch to “Physical” in the navigator before you do so) or click on “Excel Export” in the context menu of the dependency view.  This option populates an Excel spreadsheet with a list of all your dependencies.  It also marks the dependencies that violate any of your architecture rules.

Metrics Evaluation in SonarJ


For projects with a size of up to 50k bytecode instructions (approx. 20k lines of code) SonarJ can be used free of charge.  A commercial license is available for commercial projects.  The Sonar 1.2 plugin for SonarJ is under the Apache license v2.  There are several video tutorials explaining how SonarJ is used.
Dependency Architecture

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Common Firewall Misconfigurations and How to Address Them
  • How Elasticsearch Works
  • The Beauty of Java Optional and Either
  • How To Select Multiple Checkboxes in Selenium WebDriver Using Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: