The Artima Developer Community
Sponsored Link

Java Buzz Forum
Detecting Cycles with Classycle

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Tim Vernum

Posts: 58
Nickname: tpv
Registered: Dec, 2002

Tim Vernum is passionate about designing secure systems
Detecting Cycles with Classycle Posted: May 15, 2009 9:06 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Tim Vernum.
Original Post: Detecting Cycles with Classycle
Feed Title: A word used to describe something
Feed URL: http://blog.adjective.org/feed/category/Development/rss2
Feed Description: Tim's random musings on software development, java, jetty and other such frivolities.
Latest Java Buzz Posts
Latest Java Buzz Posts by Tim Vernum
Latest Posts From A word used to describe something

Advertisement

Oliver's blog entry inspired me to get off my butt and write something.

Since he was writing about checking for cyclic packages with JDepend, I though it would be worth showing how to do the same thing with classycle.

Like Oliver, I used to have some clunky ant scripts that called JDepend and tried to determine whether JDepend had detected any package cycles. It works, but as you can see from Oliver's blog it's harder than it really should be.

With classycle it's incredibly simple.

Here's a (trimmed down) classycle rules file:

        show allPaths onlyFailures  
        {root} = com.example.system  
        [all] = ${root}.*  
        check absenceOfPackageCycles > 1 in [all]

It checks all the classes in the com.example.system.* packages. The only rule that I've specified here is to check for package cycles, but classycle is much more powerful than that, and we use it to check layering, and to check that our package dependencies conform to certain rules (e.g. com.example.system.ui and com.example.system.persist must be independent of one another)

Here's the ant snippet to drive it:

        <classycleDependencyCheck 
         definitionFile="classycle.ddf"
         failOnUnwantedDependencies="true"> 
                <fileset refid="fileset.classes" /> 
        </classycleDependencyCheck>

(You'll need to add the appropriate taskdef for classycle)

Like Oliver I'm a big believer in setting up automated tools to prevent spaghetti code - I just think classycle is a simpler tool than JDepend.

Read: Detecting Cycles with Classycle

Topic: Answer to Monday's Type Parameter Question Previous Topic   Next Topic Topic: Yahoo wins round in Oregon nude photo court battle, not liable for third-party posting

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use