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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • 7 Tips for Using Instrumentation and Metrics To Align Site Reliability With Business Goals
  • Quality Engineering Design for AI Platform Adoption
  • Applying DevOps to API Development for APIOps

Trending

  • The Self-Hosting Math Changed While We Were Still Arguing About Sovereignty
  • GenAI Security Gateway: An End-to-End Architecture
  • Spring AI on Local LLMs
  • Microsoft Fabric Throttling: Diagnose Before You Scale

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. JDepend design metrics in CI

JDepend design metrics in CI

By 
James Betteley
·
Oct. 21, 11 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
13.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

this article is intended to give the reader enough information to understand what jdepend is, what it does, and how to use it in a maven build. it’s a kind of cheat sheet, if you like.

what is it?

jdepend is more of a design metric than a code metric, it gives you information about your classes with regards to how they’re related to each other. using this information you should be able to identify any unwanted or dubious dependencies.

how does it do that?

it traverses java class files and generates design quality metrics, such as:

  • number of classes and interfaces
  • afferent couplings (ca) – what is this?? someone probably feels very proud of themselves for coming up with this phrase. afferent coupling means the number of other packages which depend on the package being measured, in a nutshell. jdepend define this as a measure of a package’s “responsibility”
  • efferent couplings (ce) – sort of the opposite of ca. it’s a measure of the number of other packages that your package depends on
  • abstractness (a) – the ratio of abstract classes to total classes.
  • instability (i) – the ratio of efferent coupling (ce) to total coupling (ce + ca)
  • distance from the main sequence (d) – this sounds fairly wishy-washy and i’ve never paid any attention to it. it’s defined as: “an indicator of the package’s balance between abstractness and stability”. meh.

to use jdepend with maven you’ll need maven 2.0 or higher and jdk 1.4 or higher. you don’t need to install anything, as maven will sort this out for you by downloading it at build time.

here’s a snippet from one of my project poms, it comes from in the <reporting> section:

<plugin>

    <groupid>org.codehaus.mojo</groupid>

    <artifactid>jdepend-maven-plugin</artifactid>

    <configuration>

        <targetjdk>1.6</targetjdk>

        <outputdirectory>build/maven/${pom.artifactid}/target/jdepend-reports</outputdirectory>

    </configuration>

</plugin>

what you’ll get is a jdepend entry under the project reports section of your maven site, like this:

project-reports-page

maven project reports page

and this is what the actual report looks like (well, some of it):

jdepend-report

jdepend report

summary:

jdepend isn’t something i personally use very heavily, but i can understand how it could be used to good effect as a general measure of how closely related your classes are, which, in certain circumstances could prompt you to redesign or refactor your code.

i don’t think this sort of information is required on a per commit basis, so i’d be tempted to only include it in my nightly reports. however, i also use sonar, and that has a built-in measure of afferent coupling, so if you’re only interested in that measurement and you’re already running sonar, then jdepend is probably a bit of an unnecessary overhead. also, sonar itself has some good plugins which can provide architectural and design governance features, at least one of which i know implemented jdepend.




source: http://jamesbetteley.wordpress.com/2011/04/06/jdepend-design-metrics-in-ci/
Continuous Integration/Deployment Design Metric (unit)

Opinions expressed by DZone contributors are their own.

Related

  • DORA Metrics: Tracking and Observability With Jenkins, Prometheus, and Observe
  • 7 Tips for Using Instrumentation and Metrics To Align Site Reliability With Business Goals
  • Quality Engineering Design for AI Platform Adoption
  • Applying DevOps to API Development for APIOps

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook