Jeremy Rayner on java and other stuff.

All | AudioDrama | Chatter | Fun | Groovy | Java | Life

Free Pasta helps find bad smells
Posted on 07 Aug 2003
As I was poking around, getting familiar with the refactoring book again, I did a quick google for automatic detection of "Bad Smells" in code, and came up with the handy, and FREE tool from compuware called Pasta.

I downloaded the 1.3Mb jar, did the usual magic invocation java -jar pasta.jar and pointed it at some source of mine. It does a load of analysis and comes up with a rather pretty dependancy diagram, with all the classes/methods with no dependancies of their own at the bottom, and then other classes neatly layered on top based on their dependancies until the top of the diagram you can see the classes with no dependant classes.

funky screenshot of pasta
click to enlarge screenshot

If you look closer at the diagram, you can see that an 'acyclic dependancies principle' metric is being applied at the time, which basically means if you have arrows pointing up and down the diagram from/to any one class, then it is a bad thing. Which winds up saying my 'Cal' class smells bad.

The 'acyclic dependancies principle' or ADP is one of many metrics which you can find out more detail of in this pdf (A bit in depth really)

I like the simplicity of Pasta, things that smell bad are coloured in red, almost identical to the performance guides that JProbe gives me.

It then goes onto give this detail as to what offending dependancies it has, in this manner:

From "BlogState" to "Cal"
FromToDependency TypeLine
BlogState.getCalendarCalreturn type131
BlogState.setCalendar.cCalparameter type135
BlogState.calendarCalfield type185
 
From "Cal" to "BlogState"
FromToDependency TypeLine
Cal.setCurrentDate.stateBlogStateparameter type61
Cal.setCurrentDate.stateBlogStateparameter type67
Cal.setCurrentDate.stateBlogStateparameter type76
Cal.populateDaysBlogState.getEntriesmethod call204
Cal.populateDaysBlogState.getEntriesmethod call205
Cal.populateDays.stateBlogStateparameter type164

Not a bad tool, for a freebie, it won't refactor your code, but it will point you in some good directions. Go on download it now, whack it over your code and see what smells bad. I'd not see it before, and was pleasantly surprised. There is also another tool fresh on the scene called metrics over at sourceforge, not checked it out yet...

07 Aug 2003 |

 

 
August 2003
SunMonTueWedThuFriSat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Prev | Today | Next

rss:subscribe (All)



What I'm reading
my feed aggregator ->box

My websites
London Java Meetups
Programming Projects
Elite in Java
megg
Blogmento
Jez's Photos
Fantasy Stock Market
Cool Saxophonist
Doctor Who Audios
Pisces Audios

Other Blogs
Mike Cannon-Brookes
James Strachan
Joe Walnes
Sam Dalton
Simon Brown
Cameron Purdy
Mike Roberts
Erik C. Thauvin
John Martin
Manfred Riem

B5 d++ t++ k s+ u- f
i+ o+ x-- e+ l- c--

powered by blogmento