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 Video Library
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
View Events Video Library
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
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

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • 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
  • 5 Key Metrics in Test Automation and How to Track Them

Trending

  • Memory Management in Java: An Introduction
  • Effective Tips for Debugging Complex Code in Java
  • How To Verify Database Connection From a Spring Boot Application
  • Spring Authentication With MetaMask
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. JDepend design metrics in CI

JDepend design metrics in CI

James Betteley user avatar by
James Betteley
·
Oct. 21, 11 · Interview
Like (1)
Save
Tweet
Share
12.51K Views

Join the DZone community and get the full member experience.

Join For Free

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

  • 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
  • 5 Key Metrics in Test Automation and How to Track Them

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

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: